Instructions to use xiryss/llm-course-hw3-lora with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use xiryss/llm-course-hw3-lora with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="xiryss/llm-course-hw3-lora") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("xiryss/llm-course-hw3-lora") model = AutoModelForCausalLM.from_pretrained("xiryss/llm-course-hw3-lora") 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]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use xiryss/llm-course-hw3-lora with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "xiryss/llm-course-hw3-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": "xiryss/llm-course-hw3-lora", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/xiryss/llm-course-hw3-lora
- SGLang
How to use xiryss/llm-course-hw3-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 "xiryss/llm-course-hw3-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": "xiryss/llm-course-hw3-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 "xiryss/llm-course-hw3-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": "xiryss/llm-course-hw3-lora", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use xiryss/llm-course-hw3-lora with Docker Model Runner:
docker model run hf.co/xiryss/llm-course-hw3-lora
Model Card for llm-course-hw3-lora
This model is a fine-tuned version of OuteAI/Lite-Oute-1-300M-Instruct on the cardiffnlp/tweet_eval dataset to determine tweets tonality in one of the three classes: positive, neutral or negative.
It was finetuned with LoRA to make training more memory and time efficient. Low-rank finetuning was applied only to V and K matrices of attention layers.
Training procedure
This model was trained with batch_size=32, rank = 8, alpha = 16, learning_rate = 1e-5 on cardiffnlp/tweet_eval for one epoch.
The model achieved 0.48 f1-score on the test dataset.
Comparison
Before:
Chase Headley's RBI double in the 8th inning off David Price snapped a Yankees streak of 33 consecutive scoreless innings against Blue Jays -> "The text is positive. \n The text is neutral."
Correct: neutral
After:
Chase Headley's RBI double in the 8th inning off David Price snapped a Yankees streak of 33 consecutive scoreless innings against Blue Jays -> "neutral"
Usage
from safetensors.torch import load_file
from huggingface_hub import hf_hub_download
model = AutoModelForCausalLM.from_pretrained(f"{REPO_NAME}-lora", device_map="auto")
tokenizer = AutoTokenizer.from_pretrained(f"{REPO_NAME}-lora")
tokenizer.pad_token = tokenizer.eos_token
tokenizer.padding_side = "left"
apply_peft_to_module(model, LinearWithLoRA, r=8, alpha=16, target_submodules=["v_proj", "k_proj"])
model.to(DEVICE)
path = hf_hub_download(f"{REPO_NAME}-lora", "model.safetensors")
state_dict = load_file(path)
model.load_state_dict(state_dict, strict=False)
LoRA_saved_model_accuracy = eval(model, dataset["test"], tokenizer)
print(f"Accuracy after LoRA training: {LoRA_saved_model_accuracy:.2f}")
Framework versions
- Transformers: 4.47.0
- Pytorch: 2.5.1+cu121
- Datasets: 3.3.1
- Tokenizers: 0.21.0
- Downloads last month
- 1
Model tree for xiryss/llm-course-hw3-lora
Base model
OuteAI/Lite-Oute-1-300M-Instruct