Lloro, developed by Semantix Research Labs , is a language Model that was trained to effectively perform Portuguese Data Analysis in Python. It is a fine-tuned version of codellama/CodeLlama-7b-Instruct-hf, that was trained on synthetic datasets. The fine-tuning process was performed using the QLORA metodology on a GPU A100 with 40 GB of RAM.
Model type: A 7B parameter fine-tuned on synthetic datasets.
Language(s) (NLP): Primarily Portuguese, but the model is capable to understand English as well
Lloro is built for data analysis in Portuguese contexts .
1#Import required libraries
2import torch
3from transformers import (
4 AutoModelForCausalLM,
5 AutoTokenizer
6)
7
8#Load Model
9model_name = "semantixai/LloroV2"
10base_model = AutoModelForCausalLM.from_pretrained(
11 model_name,
12 return_dict=True,
13 torch_dtype=torch.float16,
14 device_map="auto",
15 )
16
17#Load Tokenizer
18tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
19
20
21#Define Prompt
22user_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."
23system = "Provide answers in Python without explanations, only the code"
24prompt_template = f"[INST] <<SYS>>\\n{system}\\n<</SYS>>\\n\\n{user_prompt}[/INST]"
25
26#Call the model
27input_ids = tokenizer([prompt_template], return_tensors="pt")["input_ids"].to("cuda")
28
29
30outputs = base_model.generate(
31 input_ids,
32 do_sample=True,
33 top_p=0.95,
34 max_new_tokens=1024,
35 temperature=0.1,
36 )
37
38#Decode and retrieve Output
39output_text = tokenizer.batch_decode(outputs, skip_prompt=True, skip_special_tokens=False)
40display(output_text)
Using an OpenAI compatible inference server (like
vLLM)
1from openai import OpenAI
2
3client = OpenAI(
4 api_key="EMPTY",
5 base_url="http://localhost:8000/v1",
6)
7user_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."
8completion = client.chat.completions.create(temperature=0.1,frequency_penalty=0.1,model="semantixai/Lloro",messages=[{"role":"system","content":"Provide answers in Python without explanations, only the code"},{"role":"user","content":user_prompt}])
Model Dates: Lloro was trained between February 2024 and April 2024.