HuggingFaceTB/instruct-data-basics-smollm-H4
Viewer • Updated • 767 • 547 • 4
How to use Fu01978/FuadeAI-50M with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="Fu01978/FuadeAI-50M")
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("Fu01978/FuadeAI-50M")
model = AutoModelForCausalLM.from_pretrained("Fu01978/FuadeAI-50M")How to use Fu01978/FuadeAI-50M with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "Fu01978/FuadeAI-50M"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "Fu01978/FuadeAI-50M",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/Fu01978/FuadeAI-50M
How to use Fu01978/FuadeAI-50M with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "Fu01978/FuadeAI-50M" \
--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": "Fu01978/FuadeAI-50M",
"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 "Fu01978/FuadeAI-50M" \
--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": "Fu01978/FuadeAI-50M",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use Fu01978/FuadeAI-50M with Docker Model Runner:
docker model run hf.co/Fu01978/FuadeAI-50M
A 50 million parameter causal language model trained for conversational chat, built on a GPT-2 architecture with a custom tokenizer.
| Property | Value |
|---|---|
| Parameters | 51.5M |
| Architecture | GPT-2 (custom config) |
| Hidden size | 512 |
| Layers | 8 |
| Attention heads | 8 |
| Context length | 1024 tokens |
| Tokenizer | GPT-2 + custom special tokens |
| Training precision | FP16 |
| Token | Purpose |
|---|---|
<|startoftext|> |
Beginning of conversation |
<user> / </user> |
Wraps user message |
<assistant> / </assistant> |
Wraps assistant response |
<|endoftext|> |
End of conversation |
from transformers import GPT2Tokenizer, GPT2LMHeadModel
import torch
# Load model and tokenizer
tokenizer = GPT2Tokenizer.from_pretrained("Fu01978/FuadeAI-50M")
model = GPT2LMHeadModel.from_pretrained("Fu01978/FuadeAI-50M")
model.eval()
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model = model.to(device)
# Chat function
def chat(prompt, temperature=0.4, top_p=0.9, max_new_tokens=100):
formatted = (
f"{tokenizer.bos_token}"
f"<user>{prompt}</user>"
f"<assistant>"
)
inputs = tokenizer(formatted, return_tensors="pt").to(device)
with torch.no_grad():
output = model.generate(
**inputs,
max_new_tokens=max_new_tokens,
do_sample=True,
temperature=temperature,
top_p=top_p,
repetition_penalty=1.2,
no_repeat_ngram_size=3,
eos_token_id=tokenizer.eos_token_id,
pad_token_id=tokenizer.pad_token_id,
)
generated = output[0][inputs["input_ids"].shape[-1]:]
return tokenizer.decode(generated, skip_special_tokens=True).strip()
# Example usage
print(chat("Hello!"))
print(chat("Who invented the first telephone?"))
print(chat("Who are you?"))
temperature=0.45 — balanced creativity and coherence (recommended)temperature=0.2 — more focused and deterministic answerstemperature=0.8 — more creative but less reliablerepetition_penalty=1.2 — keeps responses from looping (recommended)max_new_tokens=100 — increase for longer responses