Text Generation
Transformers
Safetensors
Catalan
English
llama
llama-3
Catalan
conversational
text-generation-inference
Instructions to use catallama/CataLlama-v0.2-Instruct-SFT with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use catallama/CataLlama-v0.2-Instruct-SFT with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="catallama/CataLlama-v0.2-Instruct-SFT") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("catallama/CataLlama-v0.2-Instruct-SFT") model = AutoModelForCausalLM.from_pretrained("catallama/CataLlama-v0.2-Instruct-SFT", 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=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use catallama/CataLlama-v0.2-Instruct-SFT with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "catallama/CataLlama-v0.2-Instruct-SFT" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "catallama/CataLlama-v0.2-Instruct-SFT", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/catallama/CataLlama-v0.2-Instruct-SFT
- SGLang
How to use catallama/CataLlama-v0.2-Instruct-SFT 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 "catallama/CataLlama-v0.2-Instruct-SFT" \ --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": "catallama/CataLlama-v0.2-Instruct-SFT", "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 "catallama/CataLlama-v0.2-Instruct-SFT" \ --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": "catallama/CataLlama-v0.2-Instruct-SFT", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use catallama/CataLlama-v0.2-Instruct-SFT with Docker Model Runner:
docker model run hf.co/catallama/CataLlama-v0.2-Instruct-SFT
| license: llama3 | |
| base_model: catallama/CataLlama-v0.2-Base | |
| tags: | |
| - llama | |
| - llama-3 | |
| - Catalan | |
| model-index: | |
| - name: CataLlama-v0.2-Instruct-SFT | |
| results: [] | |
| datasets: | |
| - catallama/Catalan-Instruct-V2 | |
| language: | |
| - ca | |
| - en | |
| pipeline_tag: text-generation | |
| library_name: transformers | |
|  | |
| # CataLlama-v0.2-Instruct-SFT | |
| **CataLlama-v0.2-Instruct-SFT** is an instruct fine-tune of [catallama/CataLlama-v0.2-Base](https://huggingface.co/catallama/CataLlama-v0.2-Base) on the [catallama/Catalan-Instruct-V2](https://huggingface.co/datasets/catallama/Catalan-Instruct-V2) dataset. | |
| CataLlama-v0.2 was trained on roughly **620 million new tokens** which is almost 40% more than CataLlama-v0.1. | |
| This new (V2) SFT Dataset was built mostly from scratch and it only retained parts of the V1. | |
| On top of the existing instructions in Catalan, **250k additional instructions were translated for this model.** | |
| All the English instructions existing in the V1 of the dataset were discarded and replaced with high quality instructions scored with [RLHFlow/ArmoRM-Llama3-8B-v0.1](https://huggingface.co/RLHFlow/ArmoRM-Llama3-8B-v0.1) reward model. | |
| The model shows improved proficiency with the Catalan language while performing **significantly better than CataLlama-v0.1 on all tasks.** | |
| **This is an instruction fine-tuned model proficient on the following tasks in Catalan** | |
| - *Information extraction (suitable for RAG)* | |
| - *Named Entity Recognition (NER)* | |
| - *Translation from English to Catalan and Catalan to English* | |
| - *Summarization - both short form and long form* | |
| - *Sentiment analysis* | |
| - *Chat* | |
| **Model developers** [Laurentiu Petrea](https://www.linkedin.com/in/laurentiupetrea/) based on Llama-3 from Meta. | |
| **Model Architecture** CataLlama is an auto-regressive language model that uses an optimized transformer architecture. The tuned versions use supervised fine-tuning (SFT) and direct preference optimisation (DPO) to align with human preferences for helpfulness and safety. | |
| **License** The model uses the llama-3 license available at: [https://llama.meta.com/llama3/license](https://llama.meta.com/llama3/license) | |
| ## Benchmarks | |
| | Model | CataLlama-v0.1-Instruct-SFT | CataLlama-v0.2-Instruct-SFT | | |
| | ------------------ | --------------------------- | ------------------------------- | | |
| | MMLU 5 shot | 55.28 | **59.35** | | |
| | GSM8K cot 8 shot | 51.63 | **76.04** | | |
| ### Use with transformers | |
| See the snippet below for usage with Transformers: | |
| **The model follows the same prompt template as Llama-3 Instruct** | |
| ```python | |
| import transformers | |
| import torch | |
| model_id = "catallama/CataLlama-v0.2-Instruct-SFT" | |
| pipeline = transformers.pipeline( | |
| "text-generation", | |
| model=model_id, | |
| model_kwargs={"torch_dtype": torch.bfloat16}, | |
| device_map="auto", | |
| ) | |
| messages = [ | |
| {"role": "user", "content": "Ei com estàs avui?"}, | |
| ] | |
| prompt = pipeline.tokenizer.apply_chat_template( | |
| messages, | |
| tokenize=False, | |
| add_generation_prompt=True | |
| ) | |
| outputs = pipeline( | |
| prompt, | |
| max_new_tokens=1024, | |
| do_sample=True, | |
| temperature=0.6, | |
| top_p=0.9, | |
| ) | |
| print(outputs[0]["generated_text"][len(prompt):]) | |
| ``` | |
| ## Training procedure | |
| The model was trained **with the same prompt template of Llama-3 Instruct**. | |
| The model was trained for two epochs on **8x A100 80GB GPUs using DeepSpeed ZeRO** State-3 without CPU offloading. | |
| ### Training hyperparameters | |
| The following hyperparameters were used during training: | |
| - learning_rate: 2e-05 | |
| - distributed_type: multi-GPU | |
| - num_devices: 8 | |
| - optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08 | |
| - lr_scheduler_type: cosine | |
| - lr_scheduler_warmup_steps: 100 | |
| - num_epochs: 2 | |
| ## Intended Use | |
| **Note:** This model is not intended to beat benchmarks, but to demonstrate techniques for augmenting LLMs on new languages and preserve rare languages as part of our world heritage. | |
| **Intended Use Cases** Llama 3 is intended for commercial and research use in English. Instruction tuned models are intended for assistant-like chat, whereas pretrained models can be adapted for a variety of natural language generation tasks. | |
| **Out-of-scope** Use in any manner that violates applicable laws or regulations (including trade compliance laws). Use in any other way that is prohibited by the Acceptable Use Policy and Llama 3 Community License. Use in languages other than English**. | |
| **Note: Developers may fine-tune Llama 3 models for languages beyond English provided they comply with the Llama 3 Community License and the Acceptable Use Policy. |