--- library_name: transformers license: mit language: - ru base_model: - google/gemma-3-1b-it pipeline_tag: text-generation --- # Model Card for `gemma-3-1b-bookMeta` ## Model Details - **Model ID:** `nesemenpolkov/gemma-3-1b-it-bookMeta` - **Model Type:** Causal Language Model - **Library:** Transformers - **Framework:** PyTorch ## Model Description 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. ## Usage Below is an example of how to use the `gemma-3-1b-bookMeta` model to extract metadata from a book description: ```python 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) ``` ## Input/Output - **Input:** A text string containing book metadata. - **Output:** Extracted metadata fields such as authors, title, publisher, year, page count, translator, and illustrator. ## Limitations - The model may struggle with non-standard or incomplete book descriptions. - Accuracy may vary depending on the formatting and language of the input text. ## Ethical Considerations - Ensure that the model is used responsibly and ethically, respecting privacy and copyright laws when processing book metadata. ## Contact For more information or support, please contact the model maintainers.