ujwal55 commited on
Commit
9911c68
·
verified ·
1 Parent(s): 062a261

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
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 = 350000 # max_chars = 128000 * 3.5 (approx_chars_per_token) 448,000 characters; 448,000 - 98000(space for synopsis) = 350000
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=5000,
67
- # n_batch=128
 
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 = (