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
|
@@ -1,6 +1,10 @@
|
|
| 1 |
---
|
| 2 |
library_name: transformers
|
| 3 |
-
tags:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
---
|
| 5 |
|
| 6 |
# Model Card for Model ID
|
|
@@ -10,7 +14,8 @@ This repository provides a **LoRA adapter** for the final competition (StructEva
|
|
| 10 |
It is **not** a full base model. Please load it on top of the base model below.
|
| 11 |
|
| 12 |
## Base model
|
| 13 |
-
-
|
|
|
|
| 14 |
|
| 15 |
## Files
|
| 16 |
- `adapter_model.safetensors` : LoRA weights
|
|
@@ -19,15 +24,17 @@ It is **not** a full base model. Please load it on top of the base model below.
|
|
| 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 = "
|
| 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,
|
|
@@ -35,8 +42,17 @@ base = AutoModelForCausalLM.from_pretrained(
|
|
| 35 |
trust_remote_code=True,
|
| 36 |
)
|
| 37 |
|
| 38 |
-
model = PeftModel.from_pretrained(base, ADAPTER_REPO)
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
|
| 42 |
|
|
|
|
| 1 |
---
|
| 2 |
library_name: transformers
|
| 3 |
+
tags:
|
| 4 |
+
- peft
|
| 5 |
+
- lora
|
| 6 |
+
- qwen3
|
| 7 |
+
- structured-output
|
| 8 |
---
|
| 9 |
|
| 10 |
# Model Card for Model ID
|
|
|
|
| 14 |
It is **not** a full base model. Please load it on top of the base model below.
|
| 15 |
|
| 16 |
## Base model
|
| 17 |
+
- Base model: `Qwen/Qwen3-4B-Instruct-2507`
|
| 18 |
+
- Adapter repo: `leaf0788/structeval-lora`
|
| 19 |
|
| 20 |
## Files
|
| 21 |
- `adapter_model.safetensors` : LoRA weights
|
|
|
|
| 24 |
- `chat_template.jinja` : chat template (if used)
|
| 25 |
|
| 26 |
## How to load (Transformers + PEFT)
|
| 27 |
+
|
| 28 |
```python
|
| 29 |
import torch
|
| 30 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 31 |
from peft import PeftModel
|
| 32 |
|
| 33 |
+
BASE_MODEL = "Qwen/Qwen3-4B-Instruct-2507"
|
| 34 |
ADAPTER_REPO = "leaf0788/structeval-lora"
|
| 35 |
|
| 36 |
tokenizer = AutoTokenizer.from_pretrained(ADAPTER_REPO, trust_remote_code=True)
|
| 37 |
+
|
| 38 |
base = AutoModelForCausalLM.from_pretrained(
|
| 39 |
BASE_MODEL,
|
| 40 |
torch_dtype=torch.float16,
|
|
|
|
| 42 |
trust_remote_code=True,
|
| 43 |
)
|
| 44 |
|
| 45 |
+
model = PeftModel.from_pretrained(base, ADAPTER_REPO).eval()
|
| 46 |
+
|
| 47 |
+
# quick test
|
| 48 |
+
prompt = 'Please output JSON code.\n\nTask: Return a JSON with a single key "hello" and value "world".'
|
| 49 |
+
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
|
| 50 |
+
|
| 51 |
+
with torch.no_grad():
|
| 52 |
+
out = model.generate(**inputs, max_new_tokens=128, do_sample=False)
|
| 53 |
+
|
| 54 |
+
print(tokenizer.decode(out[0], skip_special_tokens=True))
|
| 55 |
+
|
| 56 |
|
| 57 |
|
| 58 |
|