Russian NER
Collection
Collection of ru-NLP models for different NER tasks
•
3 items
•
Updated
•
1
gemma-3-1b-bookMeta
nesemenpolkov/gemma-3-1b-it-bookMeta
The gemma-3-1b-bookMeta
model is designed to extract metadata from book descriptions. It can identify authors, titles, publishers, years, page counts, translators, and illustrators from a given text.
Below is an example of how to use the gemma-3-1b-bookMeta
model to extract metadata from a book description:
from transformers import AutoTokenizer, Gemma3ForCausalLM
import torch
model_id = "nesemenpolkov/gemma-3-1b-it-bookMeta"
model = Gemma3ForCausalLM.from_pretrained(model_id).eval()
tokenizer = AutoTokenizer.from_pretrained(model_id)
text = "Летний сад / художник Успенский М. Н. 5 мая 1967 1 л."
prompt = "Вот текст:\n{text}\nВыдели в тексте (если есть):\n-авторы (один или несколько может быть, не пересекается с названием)\n-название (обычно в начале текста, не пересекается с авторами)\n-издательство (не может включать в себя год)\n-год (четырех значное число)\n-количество страниц\n-переводчик (обычно в тексте встречается как 'пер.' или синоним)\n-илюстратор (обычно в тексте встречается как 'ил.' или синоним)\n В случае отсутствия чего либо на этом месте должна быть пустая строка в ответе".format(text=text)
messages = [
[
{
"role": "user",
"content": [{"type": "text", "text": prompt},]
},
],
]
inputs = tokenizer.apply_chat_template(
messages,
add_generation_prompt=True,
tokenize=True,
return_dict=True,
return_tensors="pt",
).to(model.device).to(torch.bfloat16)
with torch.inference_mode():
outputs = model.generate(**inputs, max_new_tokens=128)
outputs = tokenizer.batch_decode(outputs)
For more information or support, please contact the model maintainers.