Text Generation
Transformers
Safetensors
Portuguese
llama
Portuguese
Tiny-Llama
PEFT
conversational
text-generation-inference
Instructions to use lrds-code/samba-1.1B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use lrds-code/samba-1.1B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="lrds-code/samba-1.1B") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("lrds-code/samba-1.1B") model = AutoModelForCausalLM.from_pretrained("lrds-code/samba-1.1B") 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 Settings
- vLLM
How to use lrds-code/samba-1.1B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "lrds-code/samba-1.1B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "lrds-code/samba-1.1B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/lrds-code/samba-1.1B
- SGLang
How to use lrds-code/samba-1.1B 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 "lrds-code/samba-1.1B" \ --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": "lrds-code/samba-1.1B", "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 "lrds-code/samba-1.1B" \ --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": "lrds-code/samba-1.1B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use lrds-code/samba-1.1B with Docker Model Runner:
docker model run hf.co/lrds-code/samba-1.1B
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,7 +1,6 @@
|
|
| 1 |
---
|
| 2 |
language:
|
| 3 |
- pt
|
| 4 |
-
- en
|
| 5 |
license: llama2
|
| 6 |
library_name: transformers
|
| 7 |
tags:
|
|
@@ -10,16 +9,10 @@ tags:
|
|
| 10 |
- Tiny-Llama
|
| 11 |
- LLM
|
| 12 |
- PEFT
|
| 13 |
-
datasets:
|
| 14 |
-
- ju-resplande/rebel-pt
|
| 15 |
-
- paulofinardi/OIG_small_chip2_portuguese_brasil
|
| 16 |
-
- Guilherme34/Cabrita-lora-ptbr
|
| 17 |
-
- dominguesm/Canarim-Instruct-PTBR-Dataset
|
| 18 |
pipeline_tag: text-generation
|
| 19 |
widget:
|
| 20 |
-
- text:
|
| 21 |
-
|
| 22 |
-
'
|
| 23 |
---
|
| 24 |
|
| 25 |
<hr>
|
|
@@ -35,13 +28,11 @@ widget:
|
|
| 35 |
|
| 36 |
Samba é um LLM treinado em dados da língua portuguesa. O modelo é baseado no [TinyLlama-1.1B](https://huggingface.co/TinyLlama/TinyLlama-1.1B-Chat-v1.0), uma versão de 1.1B parâmetros do LLaMA-2.
|
| 37 |
|
| 38 |
-
O projeto do LLM Samba tem como objetivo fornecer mais opções de LLMs para língua portuguesa, ao mesmo tempo que disponibiliza um modelo menos complexo para que, dessa forma, usuários com menos poder computacional possam usufruir das LLMs.
|
| 39 |
-
|
| 40 |
<p align="center">
|
| 41 |
<img width="250" alt="Countries Logo" src="https://cdn-uploads.huggingface.co/production/uploads/658c21f4c1229bf113295773/d3twZrXng5eDjg_LbH4pF.png">
|
| 42 |
</p>
|
| 43 |
|
| 44 |
-
##
|
| 45 |
|
| 46 |
- **Desenvolvido por:** [Leonardo Souza](https://huggingface.co/lrds-code)
|
| 47 |
- **Tipo do Modelo:** LLaMA-Based
|
|
@@ -50,22 +41,72 @@ O projeto do LLM Samba tem como objetivo fornecer mais opções de LLMs para lí
|
|
| 50 |
|
| 51 |
## Como usar
|
| 52 |
|
|
|
|
|
|
|
| 53 |
```python
|
| 54 |
import torch
|
| 55 |
from transformers import pipeline
|
| 56 |
|
| 57 |
samba = pipeline('text-generation', model='lrds-code/samba-1.1B', torch_dtype=torch.bfloat16, device_map='auto')
|
| 58 |
|
| 59 |
-
messages = [{
|
| 60 |
-
|
| 61 |
-
{
|
| 62 |
-
|
| 63 |
|
| 64 |
prompt = samba.tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
| 65 |
-
outputs = samba(prompt, max_new_tokens=256, do_sample=False, temperature=0.1, top_k=50, top_p=0.95)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
print(outputs[0]['generated_text'])
|
| 67 |
```
|
| 68 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
<hr>
|
| 70 |
|
| 71 |
# EN - README
|
|
|
|
| 1 |
---
|
| 2 |
language:
|
| 3 |
- pt
|
|
|
|
| 4 |
license: llama2
|
| 5 |
library_name: transformers
|
| 6 |
tags:
|
|
|
|
| 9 |
- Tiny-Llama
|
| 10 |
- LLM
|
| 11 |
- PEFT
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
pipeline_tag: text-generation
|
| 13 |
widget:
|
| 14 |
+
- text: |
|
| 15 |
+
Quem foi Pedro Álvares Cabral?
|
|
|
|
| 16 |
---
|
| 17 |
|
| 18 |
<hr>
|
|
|
|
| 28 |
|
| 29 |
Samba é um LLM treinado em dados da língua portuguesa. O modelo é baseado no [TinyLlama-1.1B](https://huggingface.co/TinyLlama/TinyLlama-1.1B-Chat-v1.0), uma versão de 1.1B parâmetros do LLaMA-2.
|
| 30 |
|
|
|
|
|
|
|
| 31 |
<p align="center">
|
| 32 |
<img width="250" alt="Countries Logo" src="https://cdn-uploads.huggingface.co/production/uploads/658c21f4c1229bf113295773/d3twZrXng5eDjg_LbH4pF.png">
|
| 33 |
</p>
|
| 34 |
|
| 35 |
+
## Descrição do Modelo
|
| 36 |
|
| 37 |
- **Desenvolvido por:** [Leonardo Souza](https://huggingface.co/lrds-code)
|
| 38 |
- **Tipo do Modelo:** LLaMA-Based
|
|
|
|
| 41 |
|
| 42 |
## Como usar
|
| 43 |
|
| 44 |
+
Com o `transformers pipeline`:
|
| 45 |
+
|
| 46 |
```python
|
| 47 |
import torch
|
| 48 |
from transformers import pipeline
|
| 49 |
|
| 50 |
samba = pipeline('text-generation', model='lrds-code/samba-1.1B', torch_dtype=torch.bfloat16, device_map='auto')
|
| 51 |
|
| 52 |
+
messages = [{'role':'system',
|
| 53 |
+
'content':''},
|
| 54 |
+
{'role':'user',
|
| 55 |
+
'content':'Quantos planetas existem no sistema solar?'}]
|
| 56 |
|
| 57 |
prompt = samba.tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
| 58 |
+
outputs = samba(prompt, max_new_tokens=256, do_sample=False, temperature=0.1, top_k=50, top_p=0.95, repetition_penalty=1.1, do_sample=False)
|
| 59 |
+
print(outputs[0]['generated_text'])
|
| 60 |
+
```
|
| 61 |
+
|
| 62 |
+
Com o `transformers AutoModel`
|
| 63 |
+
|
| 64 |
+
```python
|
| 65 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, GenerationConfig
|
| 66 |
+
|
| 67 |
+
def GeneratePrompt(input, instruction):
|
| 68 |
+
if input!='' and instruction!=0:
|
| 69 |
+
return f'''Abaixo está uma instrução que descreve uma tarefa, juntamente com uma entrada que fornece mais contexto. Escreva uma resposta que complete adequadamente o pedido.
|
| 70 |
+
### Instrução
|
| 71 |
+
{instruction}
|
| 72 |
+
### Entrada
|
| 73 |
+
{input}'''
|
| 74 |
+
else:
|
| 75 |
+
return f'''Abaixo está uma instrução que descreve uma tarefa, juntamente com uma entrada que fornece mais contexto. Escreva uma resposta que complete adequadamente o pedido.
|
| 76 |
+
### Instrução
|
| 77 |
+
{instruction}
|
| 78 |
+
### Entrada'''
|
| 79 |
+
|
| 80 |
+
model_config = GenerationConfig.from_model_config(model.generation_config)
|
| 81 |
+
model.generation_config.temperature = 0.1
|
| 82 |
+
|
| 83 |
+
model = AutoModelForCausalLM.from_pretrained('lrds-code/samba-1.1B')
|
| 84 |
+
tokenizer = AutoTokenizer.from_pretrained('lrds-code/samba-1.1B')
|
| 85 |
+
|
| 86 |
+
instruction = 'Quantos planetas existem no sistema solar?'
|
| 87 |
+
text = GeneratePrompt(input='', instruction=instruction)
|
| 88 |
+
inputs = tokenizer(text, return_tensors='pt')
|
| 89 |
+
outputs = model.generate(input_ids=inputs['input_ids'], attention_mask=inputs['attention_mask'], generation_config=model_config, repetition_penalty=1.1, do_sample=False)
|
| 90 |
print(outputs[0]['generated_text'])
|
| 91 |
```
|
| 92 |
|
| 93 |
+
## Prompt para Finetune
|
| 94 |
+
|
| 95 |
+
Para o finetune do Samba utilizamos o template [Alpaca](https://huggingface.co/datasets/yahma/alpaca-cleaned).
|
| 96 |
+
|
| 97 |
+
```python
|
| 98 |
+
Abaixo está uma instrução que descreve uma tarefa, juntamente com uma entrada que fornece mais contexto. Escreva uma resposta que complete adequadamente o pedido.
|
| 99 |
+
### Instrução
|
| 100 |
+
{instruction}
|
| 101 |
+
### Entrada
|
| 102 |
+
{input}
|
| 103 |
+
### Resposta
|
| 104 |
+
{output}
|
| 105 |
+
```
|
| 106 |
+
|
| 107 |
+
## Parâmetros importantes
|
| 108 |
+
|
| 109 |
+
|
| 110 |
<hr>
|
| 111 |
|
| 112 |
# EN - README
|