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:
# 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
|
@@ -22,6 +22,13 @@ It is **not** a full base model. Please load it on top of the base model below.
|
|
| 22 |
- `adapter_config.json` : LoRA config (PEFT)
|
| 23 |
- `tokenizer.json`, `tokenizer_config.json`, `vocab.json`, `merges.txt` : tokenizer files
|
| 24 |
- `chat_template.jinja` : chat template (if used)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
## How to load (Transformers + PEFT)
|
| 27 |
|
|
@@ -247,16 +254,18 @@ Carbon emissions can be estimated using the [Machine Learning Impact calculator]
|
|
| 247 |
|
| 248 |
[More Information Needed]
|
| 249 |
|
|
|
|
|
|
|
| 250 |
## Quick test generation
|
| 251 |
```python
|
| 252 |
import torch
|
| 253 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 254 |
from peft import PeftModel
|
| 255 |
|
| 256 |
-
BASE_MODEL = "
|
| 257 |
ADAPTER_REPO = "leaf0788/structeval-lora"
|
| 258 |
|
| 259 |
-
tokenizer = AutoTokenizer.from_pretrained(
|
| 260 |
base = AutoModelForCausalLM.from_pretrained(
|
| 261 |
BASE_MODEL,
|
| 262 |
torch_dtype=torch.float16,
|
|
@@ -265,10 +274,12 @@ base = AutoModelForCausalLM.from_pretrained(
|
|
| 265 |
)
|
| 266 |
model = PeftModel.from_pretrained(base, ADAPTER_REPO).eval()
|
| 267 |
|
| 268 |
-
prompt =
|
| 269 |
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
|
| 270 |
|
| 271 |
with torch.no_grad():
|
| 272 |
out = model.generate(**inputs, max_new_tokens=128, do_sample=False)
|
| 273 |
|
| 274 |
-
|
|
|
|
|
|
|
|
|
| 22 |
- `adapter_config.json` : LoRA config (PEFT)
|
| 23 |
- `tokenizer.json`, `tokenizer_config.json`, `vocab.json`, `merges.txt` : tokenizer files
|
| 24 |
- `chat_template.jinja` : chat template (if used)
|
| 25 |
+
- > Note: This repository contains **LoRA adapter weights only**. You must download the base model (`Qwen/Qwen3-4B-Instruct-2507`) separately.
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
## Requirements
|
| 29 |
+
- `transformers` (Qwen3対応の版)
|
| 30 |
+
- `peft`
|
| 31 |
+
- `torch`
|
| 32 |
|
| 33 |
## How to load (Transformers + PEFT)
|
| 34 |
|
|
|
|
| 254 |
|
| 255 |
[More Information Needed]
|
| 256 |
|
| 257 |
+
## Quick test generation
|
| 258 |
+
```python
|
| 259 |
## Quick test generation
|
| 260 |
```python
|
| 261 |
import torch
|
| 262 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 263 |
from peft import PeftModel
|
| 264 |
|
| 265 |
+
BASE_MODEL = "Qwen/Qwen3-4B-Instruct-2507"
|
| 266 |
ADAPTER_REPO = "leaf0788/structeval-lora"
|
| 267 |
|
| 268 |
+
tokenizer = AutoTokenizer.from_pretrained(BASE_MODEL, trust_remote_code=True)
|
| 269 |
base = AutoModelForCausalLM.from_pretrained(
|
| 270 |
BASE_MODEL,
|
| 271 |
torch_dtype=torch.float16,
|
|
|
|
| 274 |
)
|
| 275 |
model = PeftModel.from_pretrained(base, ADAPTER_REPO).eval()
|
| 276 |
|
| 277 |
+
prompt = 'Please output JSON code.\n\nTask: Return a JSON with a single key "hello" and value "world".'
|
| 278 |
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
|
| 279 |
|
| 280 |
with torch.no_grad():
|
| 281 |
out = model.generate(**inputs, max_new_tokens=128, do_sample=False)
|
| 282 |
|
| 283 |
+
gen = tokenizer.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True)
|
| 284 |
+
print(gen)
|
| 285 |
+
|