Views
No views yet
unsloth/llama-3-8b-Instruct-bnb-4bit| Metric | Score | Description |
|---|---|---|
| SARI | 39.92 | Main simplification metric (Keep/Add/Del). |
| BLEU | 22.97 | N-gram precision against reference. |
| COMET | ~0.76 | Semantic similarity. |
| ROUGE-L | 0.44 | Recall-based metric (Longest Common Subsequence). |
| Type | Text |
|---|---|
| Original (Input) | "onicosimicotica y perionixis" |
| Reference (Gold) | "infección por hongos de la uña del pie" |
| Model Prediction | "infección de la uña del dedo del pie" |
unsloth. It runs 2x faster and uses 60% less memory.1# 1. Install Unsloth
2# !pip install "unsloth[colab-new] @ git+[https://github.com/unslothai/unsloth.git](https://github.com/unslothai/unsloth.git)"
3# !pip install --no-deps "xformers<0.0.27" "trl<0.9.0" peft accelerate bitsandbytes
4
5from unsloth import FastLanguageModel
6import torch
7
8# 2. Load Model & Tokenizer
9model_name = "Jordiett/llama3-8b-claramed-qlora"
10max_seq_length = 512
11dtype = None
12load_in_4bit = True
13
14model, tokenizer = FastLanguageModel.from_pretrained(
15 model_name = model_name,
16 max_seq_length = max_seq_length,
17 dtype = dtype,
18 load_in_4bit = load_in_4bit,
19)
20FastLanguageModel.for_inference(model)
21
22# 3. Define the Prompt (Alpaca Style)
23alpaca_prompt = """Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
24
25### Instruction:
26Actúa como un doctor experto. Simplifica el siguiente texto médico técnico al español claro para un paciente.
27
28### Input:
29{}
30
31### Response:
32"""
33
34# 4. Run Inference
35text_to_simplify = "El paciente presenta cefalea tensional crónica y odinofagia." # Example
36
37inputs = tokenizer(
38[
39 alpaca_prompt.format(text_to_simplify)
40], return_tensors = "pt").to("cuda")
41
42outputs = model.generate(**inputs, max_new_tokens = 128, use_cache = True, temperature = 0.0)
43result = tokenizer.batch_decode(outputs, skip_special_tokens = True)
44
45print(result[0].split("### Response:")[-1].strip())
46# Output expected: "El paciente tiene dolor de cabeza constante y dolor al tragar."