Skip to content

Commit 724950c

Browse files
authored
Merge pull request #17 from ittia-research/dev
change to multi-sources mode
2 parents fe03620 + 405070b commit 724950c

20 files changed

+701
-207
lines changed

Dockerfile.local

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
FROM pytorch/pytorch:2.4.0-cuda12.4-cudnn9-runtime
2+
23
WORKDIR /app
4+
35
COPY requirements.*.txt /app
46
RUN pip install --no-cache-dir -r requirements.base.txt
57
RUN pip install --no-cache-dir -r requirements.local.txt
6-
COPY . /app
7-
EXPOSE 8000
8+
89
WORKDIR /app/src
10+
11+
COPY ./src .
12+
13+
EXPOSE 8000
14+
915
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]

Dockerfile.remote

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
FROM python:3.11-slim-bookworm
2+
23
WORKDIR /app
4+
35
COPY requirements.base.txt /app
46
RUN pip install --no-cache-dir -r requirements.base.txt
5-
COPY . /app
6-
EXPOSE 8000
7+
78
WORKDIR /app/src
9+
10+
COPY ./src .
11+
12+
EXPOSE 8000
13+
814
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ LLM
5555

5656
Embedding:
5757
- [ ] chunk size optimize
58-
- [ ] Ollama embedding performance
5958

6059
Contexts
6160
- [ ] Filter out non-related contexts before send for verdict
@@ -66,9 +65,15 @@ Retrieval
6665
### pipeline
6766
DSPy:
6867
- [ ] make dspy.settings apply to sessions only in order to support multiple retrieve index
68+
- [ ] choose the right LLM temperature
69+
- [ ] better training datasets
6970

7071
### Retrival
7172
- [ ] Better retrival solution: high performance, concurrency, multiple index, index editable.
73+
- [ ] Getting more sources when needed.
74+
75+
### Verdict
76+
- [ ] Set final verdict standards.
7277

7378
### Toolchain
7479
- [ ] Evaluate MLOps pipeline

datasets/HotPotQA/HotPotQA_statement_verdict.ipynb

Lines changed: 260 additions & 54 deletions
Large diffs are not rendered by default.

docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ services:
22
check:
33
image: ittia/check:remote
44
container_name: check
5+
volumes:
6+
- /data/cache:/data/cache
57
env_file:
68
- ./infra/env.d/check
79
ports:

docs/changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,7 @@
33
- Change from AutoGen to plain OpenAI, since AutoGen AssistantAgent adds system role which are not compateble with Gemma 2 + vllm.
44

55
## pipeline
6+
2024/8/26:
7+
- Changed to multi-sources mode (divide sources based on hostname), instead of use all web search results as one single source.
68
2024/8/13:
79
- Introduce DSPy to replace the get verdict part, with multi-step reasoning.

infra/env.d/check

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
1+
CONCURRENCY_VERDICT=8
2+
3+
DSP_CACHEBOOL=True
4+
DSP_CACHEDIR=/data/cache
5+
16
EMBEDDING_API_KEY=<CHANGE_ME>
2-
EMBEDDING_BASE_URL=http://ollama:11434
7+
EMBEDDING_BASE_URL=http://infinity:7997
8+
EMBEDDING_BATCH_SIZE=1024
39
EMBEDDING_MODEL_DEPLOY=api
4-
EMBEDDING_MODEL_NAME=jina/jina-embeddings-v2-base-en
10+
EMBEDDING_MODEL_NAME=jinaai/jina-embeddings-v2-base-en
11+
EMBEDDING_SERVER_TYPE=infinity
512
INDEX_CHUNK_SIZES=[2048, 512, 128]
613

7-
LLM_MODEL_NAME=google/gemma-2-27b-it
14+
LLM_MODEL_NAME=mistralai/Mistral-Nemo-Instruct-2407
815
OPENAI_API_KEY=<CHANGE_ME>
916
OPENAI_BASE_URL=http://localhost:8000/v1
1017

18+
OPTIMIZER_FILE_NAME=verdict_MIPROv2.json
19+
1120
RERANK_API_KEY=<CHANGE_ME>
1221
RERANK_BASE_URL=http://infinity:7997
1322
RERANK_MODEL_DEPLOY=api

src/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ async def fact_check(input):
5757
verdict = await run_in_threadpool(pipeline.get_verdict, search_json=search, statement=statement)
5858
logger.info(f"Verdict: {verdict}")
5959
except Exception as e:
60-
logger.error(f"Getting verdict for statement {statement} failed: {e}")
60+
logger.error(f"Getting verdict for statement '{statement}' failed: {e}")
6161
continue
6262

6363
verdicts.append(verdict)

src/modules/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
llm_long = dspy.OpenAI(model=settings.LLM_MODEL_NAME, api_base=f"{settings.OPENAI_BASE_URL}/", max_tokens=500, stop='\n\n')
1111

1212
from .citation import Citation
13+
from .context_verdict import ContextVerdict
1314
from .retrieve import LlamaIndexRM
1415
from .search import Search
1516
from .search_query import SearchQuery
16-
from .statements import Statements
17-
from .verdict import Verdict
17+
from .statements import Statements

src/modules/citation.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import dspy
22

3-
# TODO: citation needs higher token limits
43
class GenerateCitedParagraph(dspy.Signature):
54
"""Generate a paragraph with citations."""
6-
context = dspy.InputField(desc="may contain relevant facts")
5+
context = dspy.InputField(desc="May contain relevant facts.")
76
statement = dspy.InputField()
87
verdict = dspy.InputField()
9-
paragraph = dspy.OutputField(desc="includes citations")
10-
8+
paragraph = dspy.OutputField(desc="Includes citations.")
9+
1110
"""Generate citation from context and verdict"""
1211
class Citation(dspy.Module):
1312
def __init__(self):

0 commit comments

Comments
 (0)