Downloads · 30 days
5
5% of all-time downloads
LenaVolkova/llama-3.1-8b-armenian-address-extraction-lora
llama-3.1-8b-armenian-address-extraction-lora is a text generation model from LenaVolkova. Use it when you need the model to write or continue text. It is set up for peft.
This is a LoRA adapter model fine-tuned on top of unsloth/meta-llama-3.1-8b-instruct-bnb-4bit to perform structured address extraction from raw, unstructured Armenian texts (such as planned utility maintenance announc…
Downloads · 30 days
5
5% of all-time downloads
All-time downloads
99
Public
Repo size
185 MB
Likes
0
Public
Click a slice to open those files.
.safetensors168 MB · 91%
From the Hugging Face model README
This is a LoRA adapter model fine-tuned on top of unsloth/meta-llama-3.1-8b-instruct-bnb-4bit to perform structured address extraction from raw, unstructured Armenian texts (such as planned utility maintenance announcements).
It extracts details including region, city, settlement type, district, street name, and building lists, and formats the output strictly as a JSON array.
hy)unsloth/meta-llama-3.1-8b-instruct-bnb-4bitThis model is fine-tuned to extract structured address components from Armenian texts. Given an unstructured announcement, it parses the locations and outputs them as a clean JSON array.
region: Province or region (մարզ) name.cityname: City or village name.citytype: Settlement type (քաղաք / գյուղ).district: District/neighborhood.street: Street name.bldnum: Specific building number.bldlist: Ranges or list of building numbers.For downstream systems, it is recommended to set a low temperature (e.g., 0.1) during generation to ensure that the output remains strictly valid JSON and adheres strictly to the input context.
You can load and run the adapter using unsloth and transformers:
import json
from unsloth import FastLanguageModel
max_seq_length = 1024
dtype = None
load_in_4bit = True
# 1. Load model and tokenizer
model, tokenizer = FastLanguageModel.from_pretrained(
model_name = "LenaVolkova/llama-3.1-8b-armenian-address-extraction-lora",
max_seq_length = max_seq_length,
dtype = dtype,
load_in_4bit = load_in_4bit,
)
FastLanguageModel.for_inference(model)
# 2. Define prompt structure matching training format
SYSTEM_PROMPT = (
"You are a helpful assistant that extracts addresses from Armenian text "
"and returns them strictly in JSON format with the following fields: "
"region, cityname, citytype, district, street, bldnum, bldlist"
)
def extract_address(armenian_text):
prompt = (
f"<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\n{SYSTEM_PROMPT}<|eot_id|>"
f"<|start_header_id|>user<|end_header_id|>\n\nИзвлеки адрес из следующего текста:\n{armenian_text}<|eot_id|>"
f"<|start_header_id|>assistant<|end_header_id|>\n\n"
)
inputs = tokenizer([prompt], return_tensors = "pt").to("cuda")
outputs = model.generate(
**inputs,
max_new_tokens = 1024,
use_cache = True,
temperature = 0.1,
top_p = 0.9
)
generated_tokens = outputs[0][inputs.input_ids.shape[1]:]
response_text = tokenizer.decode(generated_tokens, skip_special_tokens=True).strip()
try:
return json.loads(response_text)
except json.JSONDecodeError:
return response_text
# Example execution
text = "Ես ապրում եմ Հայաստանում, Երևան քաղաքում, Ամիրյան փողոց, շենք 4։"
print(extract_address(text))
#Expected result: [{'region': 'Երևան', 'cityname': 'Երևան', 'citytype': 'քաղաք', 'district': 'Աջափնյակ', 'street': 'Ամիրյան փողոց', 'bldnum': '4', 'bldlist': None}]
The model was trained on a curated dataset of Armenian utility alerts. The dataset was split into:
adamw_8bitlinearbf16 (Bfloat16 enabled)q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_projnoneThe model loss converged steadily over 100 steps: