Skip to content

Commit efc1809

Browse files
authored
Merge pull request #3 from ittia-research/dev
add env RAG_CHUNK_SIZES
2 parents b0ddfd5 + 29bfbd0 commit efc1809

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ RAG_MODEL_DEPLOY=local
88
RERANK_MODEL_NAME=BAAI/bge-reranker-v2-m3
99
RERANK_BASE_URL=http://xinference:9997/v1
1010
SEARCH_BASE_URL=https://s.jina.ai
11+
RAG_CHUNK_SIZES=[4096, 1024, 256]

src/index.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def get_contexts(statement, keywords, text):
9797
document = Document(text=text)
9898
index = build_automerging_index(
9999
[document],
100-
chunk_sizes=[8192, 2048, 512],
100+
chunk_sizes=settings.RAG_CHUNK_SIZES,
101101
) # todo: will it better to use retriever directly?
102102

103103
query_engine = get_automerging_query_engine(index, similarity_top_k=16)

src/settings.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import os
1+
import os, ast
22

33
class Settings:
44
def __init__(self):
@@ -15,4 +15,12 @@ def __init__(self):
1515
# set RAG model deploy mode
1616
self.RAG_MODEL_DEPLOY = os.environ.get("RAG_MODEL_DEPLOY") or "local"
1717

18+
# set RAG chunk sizes
19+
self.RAG_CHUNK_SIZES = [4096, 1024, 256]
20+
_chunk_sizes = os.environ.get("RAG_CHUNK_SIZES")
21+
try:
22+
self.RAG_CHUNK_SIZES = ast.literal_eval(_chunk_sizes)
23+
except:
24+
pass
25+
1826
settings = Settings()

src/utils.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,8 @@ async def get_homepage():
191191
192192
[Usage] {settings.PROJECT_HOSTING_BASE_URL}/YOUR_FACT_CHECK_QUERY
193193
194+
[Source] https://github.com/ittia-research/check
195+
194196
{md}
195197
"""
196198
return md
@@ -201,6 +203,7 @@ async def get_stack():
201203
"LLM model": settings.LLM_MODEL_NAME,
202204
"Embedding model": settings.EMBEDDING_MODEL_NAME,
203205
"Rerank model": settings.RERANK_MODEL_NAME,
206+
"RAG chunk sizes": settings.RAG_CHUNK_SIZES,
204207
"RAG deploy mode": settings.RAG_MODEL_DEPLOY,
205208
}
206209
return stack

0 commit comments

Comments
 (0)