Instructions to use kreasof-ai/Liquid-Thinking-Preview with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use kreasof-ai/Liquid-Thinking-Preview with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="kreasof-ai/Liquid-Thinking-Preview") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("kreasof-ai/Liquid-Thinking-Preview") model = AutoModelForCausalLM.from_pretrained("kreasof-ai/Liquid-Thinking-Preview", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use kreasof-ai/Liquid-Thinking-Preview with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "kreasof-ai/Liquid-Thinking-Preview" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "kreasof-ai/Liquid-Thinking-Preview", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/kreasof-ai/Liquid-Thinking-Preview
- SGLang
How to use kreasof-ai/Liquid-Thinking-Preview with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "kreasof-ai/Liquid-Thinking-Preview" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "kreasof-ai/Liquid-Thinking-Preview", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "kreasof-ai/Liquid-Thinking-Preview" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "kreasof-ai/Liquid-Thinking-Preview", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Unsloth Desktop
- Docker Model Runner
How to use kreasof-ai/Liquid-Thinking-Preview with Docker Model Runner:
docker model run hf.co/kreasof-ai/Liquid-Thinking-Preview
Liquid-Thinking-Preview
This repository contains a full-parameter fine-tuned version of LiquidAI/LFM2-1.2B on the HelpingAI/Intermediate-Thinking-130k dataset. The goal of this fine-tune is to enhance the model's ability to perform step-by-step reasoning and solve problems that require intermediate thought processes.
This model was trained with high efficiency using the Unsloth library.
- GGUF Quantizations: For CPU inference, GGUF versions are available in the GGUF repository here.
Model Details
- Base Model: LiquidAI/LFM2-1.2B
- Dataset: HelpingAI/Intermediate-Thinking-130k
- Fine-tuning Method: Full Parameter Fine-tuning.
- Frameworks: Unsloth, Transformers, PyTorch, TRL.
How to Use with Unsloth
You can easily run this model for fast inference using the unsloth library.
First, install the necessary packages:
pip install "unsloth[colab-new] @ git+https://github.com/unslothai/unsloth.git"
pip install --no-deps git+https://github.com/huggingface/transformers.git
pip install --no-deps causal-conv1d==1.5.0.post8
Next, use the following Python code to load the model and generate text:
from unsloth import FastModel
import torch
from transformers import TextStreamer
model_repo_id = "kreasof-ai/Liquid-Thinking-Preview"
model, tokenizer = FastModel.from_pretrained(
model_name = model_repo_id,
dtype = None, # None for auto detection
load_in_4bit = True, # Use 4bit quantization for faster inference
)
# Define the conversation
messages = [{
"role": "user",
"content": "Explain the step-by-step process of photosynthesis in simple terms.",
}]
# Apply the chat template
inputs = tokenizer.apply_chat_template(
messages,
add_generation_prompt = True, # Must add for generation
return_tensors = "pt",
).to("cuda")
# Set up the streamer for real-time output
streamer = TextStreamer(tokenizer, skip_prompt = True)
# Generate the response
_ = model.generate(
**inputs,
max_new_tokens = 4096,
# Recommended generation parameters from LiquidAI
temperature = 0.3,
min_p = 0.15,
repetition_penalty = 1.05,
use_cache = True,
streamer = streamer,
)
Training Procedure
Data Preprocessing
The HelpingAI/Intermediate-Thinking-130k dataset, consisting of instruction and output pairs, was formatted into a conversational format using the LFM2's chat template. The template follows this structure:
<|im_start|>user
{instruction}<|im_end|>
<|im_start|>assistant
{output}<|im_end|>
The training loss was calculated only on the assistant's responses (train_on_responses_only), encouraging the model to learn the desired output format and reasoning style without being penalized for the user's prompt.
Hyperparameters
The model was trained with the following hyperparameters using trl.SFTTrainer:
| Hyperparameter | Value |
|---|---|
per_device_train_batch_size |
8 |
gradient_accumulation_steps |
4 |
Effective Batch Size |
32 |
num_train_epochs |
3 |
learning_rate |
4e-5 |
lr_scheduler_type |
cosine |
warmup_ratio |
0.1 |
optim |
adamw_torch |
weight_decay |
0.01 |
max_seq_length |
8192 |
seed |
3407 |
Training Results
The training loss curve showed a steady decrease, indicating successful learning.
Intended Use & Limitations
This model is intended for research and experimentation in multi-step reasoning, complex problem-solving, and chain-of-thought generation.
- Limitations: Like all language models, it is prone to hallucination and may produce factually incorrect or biased information.
- Out-of-Scope: This model is not designed for production use without extensive testing and safety evaluations. It should not be used for critical applications where incorrect information could cause harm.
- Downloads last month
- 25
