|
--- |
|
language: |
|
- et |
|
- en |
|
pipeline_tag: text-generation |
|
library_name: transformers |
|
tags: |
|
- conversational |
|
--- |
|
|
|
# LLammas 🐑 |
|
|
|
Llama-2-7B finetuned in two stages: |
|
1. 5B tokens of CulturaX with 75% of documents in Estonain and 25% in English (see [Llammas-base](https://huggingface.co/tartuNLP/Llammas-base)), |
|
2. Alpaca-cleaned, Alpaca-est, OASST1 top-1 English conversations, CoT and FLAN-V2 following open-instruct (both 10,000), WMT18 English-Estonian translation development data (as documents), general MTee validation English-Estonian held-out data. |
|
|
|
[Alpaca-est](https://github.com/TartuNLP/alpaca-est) is an instruction dataset generated for Estonian with *gpt-3.5-turbo-0613*, following Alpaca. More details in our [paper](https://arxiv.org/abs/2404.04042). |
|
|
|
Additional resources: |
|
* Paper: [arxiv.org/abs/2404.04042](https://arxiv.org/abs/2404.04042) |
|
* Code: [github.com/TartuNLP/llammas](https://github.com/TartuNLP/llammas) |
|
* Base model: [tartuNLP/Llammas-base](https://huggingface.co/tartuNLP/Llammas-base) |
|
* 4-bit quantized model in GGUF: [AlbertUnn/LlammasGGUF](https://huggingface.co/AlbertUnn/LlammasGGUF) |
|
* Alpaca-est dataset: [github.com/TartuNLP/alpaca-est](https://github.com/TartuNLP/alpaca-est) |
|
|
|
### Using the model |
|
|
|
|
|
|
|
Using the model in a text-generation pipeline: |
|
``` |
|
from transformers import pipeline |
|
import torch |
|
|
|
pipe = pipeline("text-generation", model="tartuNLP/Llammas", torch_dtype=torch.bfloat16, device_map="auto") |
|
|
|
messages = [ |
|
{"role": "user", "content": "Tere!"}, |
|
{"role": "assistant", "content": "Tere! Kas saaksin teid kuidagi aidata?"}, |
|
{"role": "user", "content": "Kuidas alustada kirja kirjutamist?"} |
|
] |
|
|
|
prompt = pipe.tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True) |
|
outputs = pipe(prompt, max_new_tokens=256, do_sample=True, temperature=0.6, top_k=50, top_p=0.9) |
|
print(outputs[0]["generated_text"][len(prompt):]) |
|
``` |
|
|
|
|
|
Using the model in a conversational pipeline (works with transformers==4.36.2, issues with output in newer versions): |
|
``` |
|
from transformers import pipeline, Conversation |
|
import torch |
|
|
|
pipe = pipeline("conversational", model="tartuNLP/Llammas", torch_dtype=torch.bfloat16, device_map="auto") |
|
|
|
messages = [ |
|
{"role": "user", "content": "Tere!"}, |
|
{"role": "assistant", "content": "Tere! Kas saaksin teid kuidagi aidata?"}, |
|
{"role": "user", "content": "Kuidas alustada kirja kirjutamist?"} |
|
] |
|
|
|
conversation = Conversation(messages) |
|
conversation = pipe(conversation) |
|
``` |
|
|
|
Conversational format: |
|
``` |
|
<|user|> |
|
Tere! |
|
<|assistant|> |
|
Tere! Kas saaksin teid kuidagi aidata?</s> |
|
<|user|> |
|
Kuidas alustada kirja kirjutamist? |
|
<|assistant|> |
|
Kirja kirjutamiseks alustage tervitusega, näiteks "Tere!" või "Tere hommikust!". Seejärel tutvustage ennast ja mainige, kellega kirjutate. Kirjeldage oma mõtteid või küsimusi, mida soovite arutada. Lõpetage kiri viisakalt, näiteks "Tänan teid tähelepanu eest!" või "Parimate soovidega!"</s> |
|
``` |
|
|
|
### Citation |
|
``` |
|
@misc{kuulmets2024teaching, |
|
title={Teaching Llama a New Language Through Cross-Lingual Knowledge Transfer}, |
|
author={Hele-Andra Kuulmets and Taido Purason and Agnes Luhtaru and Mark Fishel}, |
|
year={2024}, |
|
eprint={2404.04042}, |
|
archivePrefix={arXiv}, |
|
primaryClass={cs.CL} |
|
} |
|
|
|
``` |