mlabonne/FineTome-100k
Viewer • Updated • 100k • 20.3k • 268
How to use aloobun/minini-140m-it with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="aloobun/minini-140m-it")
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("aloobun/minini-140m-it")
model = AutoModelForCausalLM.from_pretrained("aloobun/minini-140m-it")
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=40)
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:]))How to use aloobun/minini-140m-it with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "aloobun/minini-140m-it"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "aloobun/minini-140m-it",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/aloobun/minini-140m-it
How to use aloobun/minini-140m-it with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "aloobun/minini-140m-it" \
--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": "aloobun/minini-140m-it",
"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 "aloobun/minini-140m-it" \
--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": "aloobun/minini-140m-it",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use aloobun/minini-140m-it with Docker Model Runner:
docker model run hf.co/aloobun/minini-140m-it
In this experiment, i finetuned minini-140m-base with training samples drawn from the FineTome-100k, and OpenMathReasoning (10k samples only). I've used the SM3 optimizer w/ cosine scheduler, and a lr of 2e-5.
I've release this initial experimental checkpoint as a foundation for further exploration and I plan to conduct more experiments with different optimization strategies(https://github.com/HomebrewML/HeavyBall) and well curated datasets, and will update the model weights accordingly.
from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer, StoppingCriteria
import torch
class MyStoppingCriteria(StoppingCriteria):
def __init__(self, target_sequence, prompt):
self.target_sequence = target_sequence
self.prompt = prompt
def __call__(self, input_ids, scores, **kwargs):
generated_text = tokenizer.decode(input_ids[0])
generated_text = generated_text.replace(self.prompt, '')
if self.target_sequence in generated_text:
return True
return False
def __len__(self):
return 1
def __iter__(self):
yield self
modelpath = "aloobun/minini-140m-it"
model = AutoModelForCausalLM.from_pretrained(
modelpath,
torch_dtype=torch.bfloat16,
device_map="cuda",
trust_remote_code=True,
)
tokenizer = AutoTokenizer.from_pretrained(
modelpath,
trust_remote_code=True,
use_fast=False,
)
messages = [
{"role": "user", "content": "what is life?"}
]
text = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True,
enable_thinking=False,
)
streamer = TextStreamer(tokenizer, skip_prompt=True)
_ = model.generate(
**tokenizer(text, return_tensors="pt").to("cuda"),
max_new_tokens=256,
temperature=0.8,
top_p=0.8,
top_k=20,
streamer=streamer,
stopping_criteria=MyStoppingCriteria("<|im_end|>", text),
pad_token_id=tokenizer.eos_token_id
)