From b0525e303dddb769d36975367b3488dbf6c0e92a Mon Sep 17 00:00:00 2001 From: "l.gabrysiak" Date: Wed, 26 Feb 2025 13:53:34 +0100 Subject: [PATCH] mod gemma --- gemma.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/gemma.py b/gemma.py index 5446312..1116d8d 100644 --- a/gemma.py +++ b/gemma.py @@ -13,12 +13,23 @@ from transformers import AutoModelForCausalLM, AutoTokenizer, TrainingArguments, embed_model = SentenceTransformer("all-MiniLM-L6-v2") # 2️⃣ Dodanie dokumentów i embeddingów -documents = [ - "Jak założyć firmę w Polsce?", - "Jak rozliczyć podatek VAT?", - "Procedura składania reklamacji w e-sklepie.", - "Jakie dokumenty są potrzebne do rejestracji działalności?" -] +def read_documents_from_file(file_path): + with open(file_path, 'r', encoding='utf-8') as file: + content = file.read() + articles = content.split('\n\n') + documents = [] + for article in articles: + if article.strip().startswith('Art.'): + documents.append(article.strip()) + return documents +#documents = [ +# "Jak założyć firmę w Polsce?", +# "Jak rozliczyć podatek VAT?", +# "Procedura składania reklamacji w e-sklepie.", +# "Jakie dokumenty są potrzebne do rejestracji działalności?" +#] +file_path = './docs/kodekspracy.txt' # Zmień na właściwą ścieżkę +documents = read_documents_from_file(file_path) embeddings = embed_model.encode(documents) # 3️⃣ Inicjalizacja FAISS i dodanie wektorów