Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -56,15 +56,20 @@ if article_file and synopsis_file:
|
|
56 |
# Anonymization
|
57 |
article_anon = anonymize_text(article)
|
58 |
synopsis_anon = anonymize_text(synopsis)
|
|
|
|
|
|
|
|
|
59 |
|
60 |
-
article_limit =
|
61 |
|
62 |
# LLM feedback
|
63 |
try:
|
64 |
llm = Llama(
|
65 |
model_path="./gemma-3-4b-it-qat-q4_0/gemma-3-4b-it-q4_0.gguf",
|
66 |
-
n_ctx=
|
67 |
-
|
|
|
68 |
)
|
69 |
|
70 |
prompt = (
|
|
|
56 |
# Anonymization
|
57 |
article_anon = anonymize_text(article)
|
58 |
synopsis_anon = anonymize_text(synopsis)
|
59 |
+
# Estimate n_ctx
|
60 |
+
total_text = article_anon + synopsis_anon
|
61 |
+
estimated_tokens = int(len(total_text)/3.5)
|
62 |
+
n_ctx = estimated_tokens + 500
|
63 |
|
64 |
+
article_limit = 80000 # max_article_chars = 32,000 tokens×3.5 (approx_chars_per_token)≈112,000 characters; 112,000 - 32000(space for synopsis)= 80000
|
65 |
|
66 |
# LLM feedback
|
67 |
try:
|
68 |
llm = Llama(
|
69 |
model_path="./gemma-3-4b-it-qat-q4_0/gemma-3-4b-it-q4_0.gguf",
|
70 |
+
n_ctx=n_ctx,
|
71 |
+
n_threads=2,
|
72 |
+
n_batch=128
|
73 |
)
|
74 |
|
75 |
prompt = (
|