Text Generation
Transformers
Safetensors
Portuguese
llama
analytics
analise-dados
portugues-BR
conversational
text-generation-inference
Instructions to use semantixai/Lloro with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use semantixai/Lloro with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="semantixai/Lloro") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("semantixai/Lloro") model = AutoModelForCausalLM.from_pretrained("semantixai/Lloro") 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
- vLLM
How to use semantixai/Lloro with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "semantixai/Lloro" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "semantixai/Lloro", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/semantixai/Lloro
- SGLang
How to use semantixai/Lloro 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 "semantixai/Lloro" \ --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": "semantixai/Lloro", "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 "semantixai/Lloro" \ --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": "semantixai/Lloro", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use semantixai/Lloro with Docker Model Runner:
docker model run hf.co/semantixai/Lloro
Update README.md
#5
by fernandofinardi - opened
README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
---
|
| 2 |
-
library_name:
|
| 3 |
base_model: codellama/CodeLlama-7b-Instruct-hf
|
| 4 |
license: apache-2.0
|
| 5 |
datasets:
|
|
@@ -42,6 +42,64 @@ Input : Text
|
|
| 42 |
|
| 43 |
Output : Text (Code)
|
| 44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
|
| 47 |
**Params**
|
|
|
|
| 1 |
---
|
| 2 |
+
library_name: transformers
|
| 3 |
base_model: codellama/CodeLlama-7b-Instruct-hf
|
| 4 |
license: apache-2.0
|
| 5 |
datasets:
|
|
|
|
| 42 |
|
| 43 |
Output : Text (Code)
|
| 44 |
|
| 45 |
+
|
| 46 |
+
**Usage**
|
| 47 |
+
|
| 48 |
+
Using Transformers
|
| 49 |
+
```python
|
| 50 |
+
#Import required libraries
|
| 51 |
+
import torch
|
| 52 |
+
from transformers import (
|
| 53 |
+
AutoModelForCausalLM,
|
| 54 |
+
AutoTokenizer
|
| 55 |
+
)
|
| 56 |
+
|
| 57 |
+
#Load Model
|
| 58 |
+
model_name = "semantixai/LloroV2"
|
| 59 |
+
base_model = AutoModelForCausalLM.from_pretrained(
|
| 60 |
+
model_name,
|
| 61 |
+
return_dict=True,
|
| 62 |
+
torch_dtype=torch.float16,
|
| 63 |
+
device_map="auto",
|
| 64 |
+
)
|
| 65 |
+
|
| 66 |
+
#Load Tokenizer
|
| 67 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
#Define Prompt
|
| 71 |
+
user_prompt = "Desenvolva um algoritmo em Python para calcular a média e a mediana dos preços de vendas por tipo de material do produto."
|
| 72 |
+
system = "Provide answers in Python without explanations, only the code"
|
| 73 |
+
prompt_template = f"[INST] <<SYS>>\\n{system}\\n<</SYS>>\\n\\n{user_prompt}[/INST]"
|
| 74 |
+
|
| 75 |
+
#Call the model
|
| 76 |
+
input_ids = tokenizer([prompt_template], return_tensors="pt")["input_ids"].to("cuda")
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
outputs = base_model.generate(
|
| 80 |
+
input_ids,
|
| 81 |
+
do_sample=True,
|
| 82 |
+
top_p=0.95,
|
| 83 |
+
max_new_tokens=1024,
|
| 84 |
+
temperature=0.1,
|
| 85 |
+
)
|
| 86 |
+
|
| 87 |
+
#Decode and retrieve Output
|
| 88 |
+
output_text = tokenizer.batch_decode(outputs, skip_prompt=True, skip_special_tokens=False)
|
| 89 |
+
display(output_text)
|
| 90 |
+
```
|
| 91 |
+
|
| 92 |
+
Using an OpenAI compatible inference server (like [vLLM](https://docs.vllm.ai/en/latest/index.html))
|
| 93 |
+
```python
|
| 94 |
+
from openai import OpenAI
|
| 95 |
+
|
| 96 |
+
client = OpenAI(
|
| 97 |
+
api_key="EMPTY",
|
| 98 |
+
base_url="http://localhost:8000/v1",
|
| 99 |
+
)
|
| 100 |
+
user_prompt = "Desenvolva um algoritmo em Python para calcular a média e a mediana dos preços de vendas por tipo de material do produto."
|
| 101 |
+
completion = client.chat.completions.create(temperature=0.1,frequency_penalty=0.1,model="semantixai/LloroV2",messages=[{"role":"system","content":"Provide answers in Python without explanations, only the code"},{"role":"user","content":user_prompt}])
|
| 102 |
+
```
|
| 103 |
|
| 104 |
|
| 105 |
**Params**
|