217 Downloads Updated 1 month ago
ollama run frob/nuextract-2.0
Updated 1 month ago
1 month ago
b4187a13ee1c · 6.0GB ·
Imported from https://huggingface.co/numind/NuExtract-2.0-8B
#!/usr/bin/env python3
import ollama
import json
import os
model = os.getenv("MODEL", "frob/nuextract-2.0:8b-q8_0")
template = {
"names": ["string"],
"places": ["string"]
}
document = "John went to the restaurant with Mary. James went to the cinema."
examples = {
"input": "Stephen is the manager at Susan's store.",
"output": """{"names": ["STEPHEN", "SUSAN"]}"""
}
messages = [
{"role": "template", "content": json.dumps(template)},
{"role": "examples.input", "content": examples["input"]},
{"role": "examples.output", "content": examples["output"]},
{"role": "user", "content": document},
]
response = ollama.chat(
model=model,
messages=messages
)
print(json.dumps({"model":model,**json.loads(response.message.content)}, indent=4))
$ python3 nuextract.py
{
"model": "frob/nuextract-2.0:8b-q8_0",
"names": [
"JOHN",
"MARY",
"JAMES"
],
"places": [
"restaurant",
"cinema"
]
}