Text Generation
Transformers
Safetensors
English
lora
smollm2
instruction-tuned
squad
conversational
Instructions to use nadaashraff/smollm2-135m-squad-lora with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use nadaashraff/smollm2-135m-squad-lora with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="nadaashraff/smollm2-135m-squad-lora") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("nadaashraff/smollm2-135m-squad-lora", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use nadaashraff/smollm2-135m-squad-lora with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "nadaashraff/smollm2-135m-squad-lora" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "nadaashraff/smollm2-135m-squad-lora", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/nadaashraff/smollm2-135m-squad-lora
- SGLang
How to use nadaashraff/smollm2-135m-squad-lora 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 "nadaashraff/smollm2-135m-squad-lora" \ --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": "nadaashraff/smollm2-135m-squad-lora", "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 "nadaashraff/smollm2-135m-squad-lora" \ --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": "nadaashraff/smollm2-135m-squad-lora", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use nadaashraff/smollm2-135m-squad-lora with Docker Model Runner:
docker model run hf.co/nadaashraff/smollm2-135m-squad-lora
smollm2-135m-squad-lora
This is a LoRA fine-tuned version of the SmolLM2-135M model trained on 5,000 samples from the SQuAD v1.1 question-answering dataset.
The goal of this fine-tune is to improve extractive question answering on short factual passages.
Model Details
- Base model:
HuggingFaceTB/smollm2-135m - Fine-tuning method: LoRA (efficient parameter-efficient fine-tuning)
- Dataset: 5k examples from SQuAD v1.1 (train/dev split)
- Epochs: 2
- Batch size: 4
- Loss after fine-tuning: ~2.21
- Hardware: Google Colab T4 GPU
- Quantization: 4-bit (bitsandbytes)
Usage
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
BASE = "HuggingFaceTB/smollm2-135m"
LORA = "nadaashraff/smollm2-135m-squad-lora"
tokenizer = AutoTokenizer.from_pretrained(BASE)
base_model = AutoModelForCausalLM.from_pretrained(BASE, device_map="auto")
model = PeftModel.from_pretrained(base_model, LORA)
prompt = """Read the following context and answer the question.
Context: Egypt ranks as the fifth worst country in the world for religious freedom. According to a 2010 Pew survey, 84% of Egyptians polled supported the death penalty for those leaving Islam.
Question: What percentage of Egyptians polled supported the death penalty for those leaving Islam?
"""
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=50)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))