Text Generation
PEFT
Safetensors
English
lora
data-to-text
text-to-data
factual-consistency
hallucination-detection
Instructions to use Loria-MosAIk/xqdt-e2e-gemma3-12b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use Loria-MosAIk/xqdt-e2e-gemma3-12b with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("google/gemma-3-12b-it") model = PeftModel.from_pretrained(base_model, "Loria-MosAIk/xqdt-e2e-gemma3-12b") - Notebooks
- Google Colab
- Kaggle
Add files using upload-large-folder tool
Browse files
README.md
CHANGED
|
@@ -42,13 +42,11 @@ TRIPLES:
|
|
| 42 |
Output as markdown table with Type and Triple columns.
|
| 43 |
```
|
| 44 |
|
| 45 |
-
## ms-swift
|
| 46 |
|
| 47 |
```python
|
| 48 |
import torch
|
| 49 |
-
from
|
| 50 |
-
from swift.llm import InferRequest, PtEngine, RequestConfig, get_model_tokenizer, get_template
|
| 51 |
-
from swift.tuners import Swift
|
| 52 |
|
| 53 |
BASE_MODEL = "google/gemma-3-12b-it"
|
| 54 |
ADAPTER_ID = "Loria-MosAIk/xqdt-e2e-gemma3-12b"
|
|
@@ -59,18 +57,20 @@ TRIPLES:
|
|
| 59 |
1. [S] Blue Spice [P] area [O] city centre
|
| 60 |
2. [S] Blue Spice [P] eat type [O] coffee shop
|
| 61 |
Output as markdown table with Type and Triple columns."""
|
|
|
|
| 62 |
|
| 63 |
-
|
| 64 |
-
model, tokenizer = get_model_tokenizer(
|
| 65 |
BASE_MODEL,
|
| 66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
)
|
| 68 |
-
model = Swift.from_pretrained(model, model_id=adapter_path, adapter_name="default")
|
| 69 |
-
template = get_template("gemma3_text", tokenizer, default_system=None)
|
| 70 |
-
engine = PtEngine.from_model_template(model, template, max_batch_size=1)
|
| 71 |
response = engine.infer(
|
| 72 |
-
[InferRequest(messages=
|
| 73 |
-
RequestConfig(max_tokens=1024, temperature=0.3),
|
| 74 |
use_tqdm=False,
|
| 75 |
)[0]
|
| 76 |
print(response.choices[0].message.content)
|
|
|
|
| 42 |
Output as markdown table with Type and Triple columns.
|
| 43 |
```
|
| 44 |
|
| 45 |
+
## ms-swift
|
| 46 |
|
| 47 |
```python
|
| 48 |
import torch
|
| 49 |
+
from swift.infer_engine import InferRequest, RequestConfig, TransformersEngine
|
|
|
|
|
|
|
| 50 |
|
| 51 |
BASE_MODEL = "google/gemma-3-12b-it"
|
| 52 |
ADAPTER_ID = "Loria-MosAIk/xqdt-e2e-gemma3-12b"
|
|
|
|
| 57 |
1. [S] Blue Spice [P] area [O] city centre
|
| 58 |
2. [S] Blue Spice [P] eat type [O] coffee shop
|
| 59 |
Output as markdown table with Type and Triple columns."""
|
| 60 |
+
MESSAGES = [{"role": "user", "content": QUERY}]
|
| 61 |
|
| 62 |
+
engine = TransformersEngine(
|
|
|
|
| 63 |
BASE_MODEL,
|
| 64 |
+
adapters=[ADAPTER_ID],
|
| 65 |
+
max_batch_size=1,
|
| 66 |
+
torch_dtype=torch.bfloat16,
|
| 67 |
+
device_map="auto",
|
| 68 |
+
template_type="gemma3_text",
|
| 69 |
+
use_hf=True,
|
| 70 |
)
|
|
|
|
|
|
|
|
|
|
| 71 |
response = engine.infer(
|
| 72 |
+
[InferRequest(messages=MESSAGES)],
|
| 73 |
+
RequestConfig(max_tokens=1024, temperature=0.3, seed=2023),
|
| 74 |
use_tqdm=False,
|
| 75 |
)[0]
|
| 76 |
print(response.choices[0].message.content)
|