AmanMussa/kazakh-instruction-v2
Viewer • Updated • 52.2k • 18.4k • 13
How to use RedBullet12/LFM3-1.7B-Kazakh with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="RedBullet12/LFM3-1.7B-Kazakh", trust_remote_code=True)
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("RedBullet12/LFM3-1.7B-Kazakh", trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained("RedBullet12/LFM3-1.7B-Kazakh", trust_remote_code=True, 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]:]))How to use RedBullet12/LFM3-1.7B-Kazakh with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "RedBullet12/LFM3-1.7B-Kazakh"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "RedBullet12/LFM3-1.7B-Kazakh",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/RedBullet12/LFM3-1.7B-Kazakh
How to use RedBullet12/LFM3-1.7B-Kazakh with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "RedBullet12/LFM3-1.7B-Kazakh" \
--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": "RedBullet12/LFM3-1.7B-Kazakh",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'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 "RedBullet12/LFM3-1.7B-Kazakh" \
--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": "RedBullet12/LFM3-1.7B-Kazakh",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use RedBullet12/LFM3-1.7B-Kazakh with Docker Model Runner:
docker model run hf.co/RedBullet12/LFM3-1.7B-Kazakh
LiquidAI/LFM3-1.7B fine-tuned to understand and answer in Kazakh, a language the base model does not support.
Given a Kazakh prompt, the base model reasons in English, misidentifies the language as Ukrainian or Kyrgyz, and usually never answers. This finetune answers directly in Kazakh.
| Setting | Value |
|---|---|
| Data | AmanMussa/kazakh-instruction-v2 (52,123 train rows, 50 held out) |
| Method | LoRA SFT with TRL, merged into full weights |
| LoRA rank / alpha | 16 / 32, all linear layers |
| Epochs / LR | 1 / 2e-4 |
| Hardware | 1x A100 (Colab), about 1 hour |
from transformers import pipeline
pipe = pipeline("text-generation", model="RedBullet12/LFM3-1.7B-Kazakh", trust_remote_code=True)
out = pipe([{"role": "user", "content": "Қазақстанның астанасы қай қала?"}],
do_sample=True, temperature=0.3, top_p=0.9, repetition_penalty=1.15,
no_repeat_ngram_size=4, max_new_tokens=512)
print(out[0]["generated_text"][-1]["content"].replace("</think>", "").strip())
Use these generation settings. With weaker repetition control the model can loop.