Text Generation
PEFT
Safetensors
English
Hindi
lora
qwen2
appointment-notes
information-extraction
unsloth
Instructions to use Algothm-LMs/Dataquality-lm with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use Algothm-LMs/Dataquality-lm with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("unsloth/Qwen2.5-3B-bnb-4bit") model = PeftModel.from_pretrained(base_model, "Algothm-LMs/Dataquality-lm") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- Unsloth Desktop
File size: 2,006 Bytes
0a06887 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | """Extraction-only target schema shared by conversion, training and evaluation."""
import json
from rubric import NOTE_TYPES, NOT_APPLICABLE, items_for, missing_items, score_from_items, validate
SCHEMA_VERSION='extraction-v1'
def target_text(output):
if not isinstance(output,dict) or set(output)!={'type','items'}:
raise ValueError('Target must contain exactly type and items')
_, _, errors = parse_extraction(output)
if errors:
raise ValueError('; '.join(errors))
return json.dumps(output,ensure_ascii=False,separators=(',',':'))
def parse_extraction(text,note=None):
errors=[]
try:
def unique(pairs):
result={}
for k,v in pairs:
if k in result:raise ValueError('duplicate JSON key: '+k)
result[k]=v
return result
obj=json.loads(text,object_pairs_hook=unique) if isinstance(text,str) else text
if not isinstance(obj,dict) or set(obj)!={'type','items'}:raise ValueError('expected exactly type and items')
t,it=obj['type'],obj['items']
if t not in NOTE_TYPES:raise ValueError('unknown type')
if not isinstance(it,dict) or set(it)!=set(items_for(t)):raise ValueError('missing or extra item keys')
if not all(isinstance(v,str) and bool(v.strip()) for v in it.values()):raise ValueError('items must be nonempty strings')
na=NOT_APPLICABLE.get(t,set())
for k,v in it.items():
if k in na and v!='n/a':errors.append(k+' must be n/a')
if k not in na and v=='n/a':errors.append(k+' cannot be n/a')
if note is not None:errors+=validate(note,t,it)
return t,it,errors
except (ValueError,TypeError,KeyError) as e:return None,{},[str(e)]
def derived_fields(output,note=None):
t,it,errors=parse_extraction(output,note)
if errors:raise ValueError('; '.join(errors))
return {'score':score_from_items(t,it),'missing_items':missing_items(t,it)}
|