Instructions to use leaf0788/structeval-lora with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use leaf0788/structeval-lora with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("leaf0788/structeval-lora", device_map="auto") - PEFT
How to use leaf0788/structeval-lora with PEFT:
Task type is invalid.
- Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files
README.md
CHANGED
|
@@ -5,7 +5,39 @@ tags: []
|
|
| 5 |
|
| 6 |
# Model Card for Model ID
|
| 7 |
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
|
| 11 |
|
|
@@ -196,4 +228,30 @@ Carbon emissions can be estimated using the [Machine Learning Impact calculator]
|
|
| 196 |
|
| 197 |
## Model Card Contact
|
| 198 |
|
| 199 |
-
[More Information Needed]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
# Model Card for Model ID
|
| 7 |
|
| 8 |
+
## What is this?
|
| 9 |
+
This repository provides a **LoRA adapter** for the final competition (StructEval / structured output generation).
|
| 10 |
+
It is **not** a full base model. Please load it on top of the base model below.
|
| 11 |
+
|
| 12 |
+
## Base model
|
| 13 |
+
- `BASE_MODEL`: <PUT_YOUR_BASE_MODEL_ID_HERE>
|
| 14 |
+
|
| 15 |
+
## Files
|
| 16 |
+
- `adapter_model.safetensors` : LoRA weights
|
| 17 |
+
- `adapter_config.json` : LoRA config (PEFT)
|
| 18 |
+
- `tokenizer.json`, `tokenizer_config.json`, `vocab.json`, `merges.txt` : tokenizer files
|
| 19 |
+
- `chat_template.jinja` : chat template (if used)
|
| 20 |
+
|
| 21 |
+
## How to load (Transformers + PEFT)
|
| 22 |
+
```python
|
| 23 |
+
import torch
|
| 24 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 25 |
+
from peft import PeftModel
|
| 26 |
+
|
| 27 |
+
BASE_MODEL = "<PUT_YOUR_BASE_MODEL_ID_HERE>"
|
| 28 |
+
ADAPTER_REPO = "leaf0788/structeval-lora"
|
| 29 |
+
|
| 30 |
+
tokenizer = AutoTokenizer.from_pretrained(ADAPTER_REPO, trust_remote_code=True)
|
| 31 |
+
base = AutoModelForCausalLM.from_pretrained(
|
| 32 |
+
BASE_MODEL,
|
| 33 |
+
torch_dtype=torch.float16,
|
| 34 |
+
device_map="auto",
|
| 35 |
+
trust_remote_code=True,
|
| 36 |
+
)
|
| 37 |
+
|
| 38 |
+
model = PeftModel.from_pretrained(base, ADAPTER_REPO)
|
| 39 |
+
model.eval()
|
| 40 |
+
|
| 41 |
|
| 42 |
|
| 43 |
|
|
|
|
| 228 |
|
| 229 |
## Model Card Contact
|
| 230 |
|
| 231 |
+
[More Information Needed]
|
| 232 |
+
|
| 233 |
+
## Quick test generation
|
| 234 |
+
```python
|
| 235 |
+
import torch
|
| 236 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 237 |
+
from peft import PeftModel
|
| 238 |
+
|
| 239 |
+
BASE_MODEL = "<PUT_YOUR_BASE_MODEL_ID_HERE>"
|
| 240 |
+
ADAPTER_REPO = "leaf0788/structeval-lora"
|
| 241 |
+
|
| 242 |
+
tokenizer = AutoTokenizer.from_pretrained(ADAPTER_REPO, trust_remote_code=True)
|
| 243 |
+
base = AutoModelForCausalLM.from_pretrained(
|
| 244 |
+
BASE_MODEL,
|
| 245 |
+
torch_dtype=torch.float16,
|
| 246 |
+
device_map="auto",
|
| 247 |
+
trust_remote_code=True,
|
| 248 |
+
)
|
| 249 |
+
model = PeftModel.from_pretrained(base, ADAPTER_REPO).eval()
|
| 250 |
+
|
| 251 |
+
prompt = "Please output JSON code.\n\nTask: Return a JSON with a single key `hello` and value `world`."
|
| 252 |
+
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
|
| 253 |
+
|
| 254 |
+
with torch.no_grad():
|
| 255 |
+
out = model.generate(**inputs, max_new_tokens=128, do_sample=False)
|
| 256 |
+
|
| 257 |
+
print(tokenizer.decode(out[0], skip_special_tokens=True))
|