Skip to content

Commit

Permalink
Merge pull request #1 from ittia-research/dev
Browse files Browse the repository at this point in the history
Update documents and lamma-index
  • Loading branch information
etwk authored Aug 4, 2024
2 parents d9347cd + e0cbdbe commit c962a87
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,15 @@ Contexts
### Calculate
- [ ] Shall we calculate percentage of true and false in the input? Any better calculation than items count?

### Logging
- [ ] Full logging on chain of events for re-producing and debugging.

### Doc
- [ ] Show current tech stack.

## Issues
- [ ] Uses many different types of models, diffcult for performance optimization and maintenance.
- [ ] LLM verdit wrong contradict to context provided.

## References
### Reports
Expand All @@ -95,5 +99,7 @@ Contexts
#### Inference
- https://console.groq.com/docs/ (free tier)

## Thanks
- Jina Reader: https://jina.ai
## Acknowledgements
- TPU Research Cloud team at Google
- Google Search
- Jina Reader
8 changes: 3 additions & 5 deletions src/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
from llama_index.core.retrievers import AutoMergingRetriever
from llama_index.core.indices.postprocessor import SentenceTransformerRerank
from llama_index.core.query_engine import RetrieverQueryEngine
from llama_index.core.llms import MockLLM

Settings.llm = None # retrieve only, do not use LLM for synthesize
Settings.llm = MockLLM() # retrieve only, do not use LLM for synthesize

import llama_index.postprocessor.jinaai_rerank.base as jinaai_rerank # todo: shall we lock package version?
jinaai_rerank.API_URL = os.environ.get("LLM_LOCAL_BASE_URL") + "/rerank" # switch to on-premise
Expand All @@ -29,7 +30,6 @@

def build_automerging_index(
documents,
llm,
chunk_sizes=None,
):
chunk_sizes = chunk_sizes or [2048, 512, 128]
Expand All @@ -46,7 +46,6 @@ def build_automerging_index(
nodes = node_parser.get_nodes_from_documents(documents)
leaf_nodes = get_leaf_nodes(nodes)
merging_context = ServiceContext.from_defaults(
llm=llm,
embed_model=embed_model,
)
storage_context = StorageContext.from_defaults()
Expand Down Expand Up @@ -99,8 +98,7 @@ def get_contexts(statement, keywords, text):
document = Document(text=text)
index = build_automerging_index(
[document],
llm=None,
chunk_sizes=[2048, 512],
chunk_sizes=[8192, 2048, 512],
) # todo: will it better to use retriever directly?

query_engine = get_automerging_query_engine(index, similarity_top_k=16)
Expand Down
1 change: 1 addition & 0 deletions src/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def get_verdict(statement, contexts):
```"""

reply = get_llm_reply(prompt)
logging.info(f"Verdict reply from LLM: {reply}")
verdict = utils.llm2json(reply)
if verdict:
verdict['statement'] = statement
Expand Down

0 comments on commit c962a87

Please sign in to comment.