-
Notifications
You must be signed in to change notification settings - Fork 1
[Rag-tools] create WS #475
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
0220876
826fcbd
25b8e0c
dbfc45c
782e9dc
e2d5e77
ae8ae21
dd20fcd
72cd97c
2f29412
cb3c0d9
45c6272
cbd8f5d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| # Ignore all files by default | ||
| * | ||
|
|
||
| # White list only the required files | ||
| !config.json | ||
| !v1 | ||
| !swagger.json |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| # syntax=docker/dockerfile:1.2 | ||
|
|
||
| FROM cnrsinist/ezs-python-server:py3.9-no24-1.0.14 | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| # Installe torch en version CPU uniquement : le wheel par défaut de pip | ||
| # embarque tout le support CUDA (bibliothèques NVIDIA), qui représente à | ||
| # lui seul plusieurs Go, totalement inutile sans GPU. | ||
| RUN pip install --no-cache-dir torch --extra-index-url https://download.pytorch.org/whl/cpu | ||
| # sentence-transformers réutilise le torch CPU déjà installé ci-dessus | ||
| # (huggingface_hub est déjà une dépendance transitive de | ||
| # sentence-transformers/transformers, pas besoin de l'installer à part). | ||
| RUN pip install --no-cache-dir sentence-transformers | ||
|
|
||
| # Télécharge le modèle, puis nettoie le cache de téléchargement HuggingFace | ||
| # dans la MÊME couche : le modèle existe sinon en double (cache + /models), | ||
| # soit environ 2,2 Go gaspillés inutilement. | ||
| RUN python -c "\ | ||
| from sentence_transformers import SentenceTransformer; \ | ||
| model = SentenceTransformer('BAAI/bge-m3'); \ | ||
| model.save('/models/BAAI/bge-m3')" \ | ||
| && rm -rf /root/.cache/huggingface | ||
|
Luc-Ank marked this conversation as resolved.
|
||
|
|
||
| WORKDIR /app/public | ||
|
|
||
| COPY --chown=daemon:daemon . /app/public/ | ||
| COPY --chown=daemon:daemon ./config.json /app/config.json | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # ws-rag-tools@0.3.0 | ||
|
|
||
| Ws to generate embeddings and use those for rag | ||
|
|
||
| Ws to generate embeddings and use those for rag |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| { | ||
| "environnement": { | ||
| "EZS_TITLE": "Ws to generate embeddings and use those for rag", | ||
| "EZS_DESCRIPTION": "Ws to generate embeddings and use those for rag", | ||
| "EZS_METRICS": true, | ||
| "EZS_CONCURRENCY": 2, | ||
|
Luc-Ank marked this conversation as resolved.
|
||
| "EZS_CONTINUE_DELAY": 60, | ||
| "EZS_NSHARDS": 32, | ||
| "EZS_CACHE": true, | ||
| "EZS_VERBOSE": false, | ||
| "NODE_OPTIONS": "--max_old_space_size=1024", | ||
| "NODE_ENV": "production", | ||
| "ILAAS_API_KEY": "real_api_key" | ||
| } | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ☑️ todo: La route |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| # These examples can be used directly in VSCode, using HTTPYac extension (anweber.vscode-httpyac) | ||
| # They are important, because used to generate the tests.hurl file. | ||
|
|
||
| # Décommenter/commenter les lignes voulues pour tester localement | ||
| @host=http://localhost:31976 | ||
| # @host=https://rag-tools.services.istex.fr | ||
|
|
||
| ### | ||
| # @name v1routeInCamelCase | ||
| # Description de la route | ||
| POST {{host}}/v1/route/in/camel/case?indent=true HTTP/1.1 | ||
| Content-Type: application/json | ||
|
|
||
| [ | ||
| { "value": "une valeur typique" }, | ||
| { "value": "en json" } | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| { | ||
| "private": true, | ||
| "name": "ws-rag-tools", | ||
| "version": "0.3.0", | ||
| "description": "Ws to generate embeddings and use those for rag", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "git+https://github.com/Inist-CNRS/web-services.git" | ||
| }, | ||
| "keywords": [ | ||
| "ezmaster" | ||
| ], | ||
| "author": "Anki Lucas <lucas.anki@inist.fr>", | ||
| "license": "MIT", | ||
| "bugs": { | ||
| "url": "https://github.com/Inist-CNRS/web-services/issues" | ||
| }, | ||
| "homepage": "https://github.com/Inist-CNRS/web-services/#readme", | ||
| "scripts": { | ||
| "version:insert:readme": "sed -i \"s#\\(${npm_package_name}.\\)\\([\\.a-z0-9]\\+\\)#\\1${npm_package_version}#g\" README.md && git add README.md", | ||
| "version:insert:swagger": "sed -i \"s/\\\"version\\\": \\\"[0-9]\\+.[0-9]\\+.[0-9]\\+\\\"/\\\"version\\\": \\\"${npm_package_version}\\\"/g\" swagger.json && git add swagger.json", | ||
| "version:insert": "npm run version:insert:readme && npm run version:insert:swagger", | ||
| "version:commit": "git commit -a -m \"release ${npm_package_name}@${npm_package_version}\"", | ||
| "version:tag": "git tag \"${npm_package_name}@${npm_package_version}\" -m \"${npm_package_name}@${npm_package_version}\"", | ||
| "version:push": "git push && git push origin \"${npm_package_name}@${npm_package_version}\"", | ||
| "version": "npm run version:insert && npm run version:commit && npm run version:tag", | ||
| "postversion": "npm run version:push", | ||
| "build:check": "DOCKER_BUILDKIT=1 docker build --check -t cnrsinist/${npm_package_name}:latest . && docker run --rm -i hadolint/hadolint hadolint - < Dockerfile ", | ||
| "build:dev": "docker build -t cnrsinist/${npm_package_name}:latest .", | ||
| "start:dev": ". ./.env 2> /dev/null; npm run build:dev && docker run -e ILAAS_API_KEY --name dev --rm --detach -p 31976:31976 cnrsinist/${npm_package_name}:latest", | ||
| "stop:dev": "docker stop dev", | ||
| "build": "docker build -t cnrsinist/${npm_package_name}:${npm_package_version} .", | ||
| "start": "docker run --rm -p 31976:31976 cnrsinist/${npm_package_name}:${npm_package_version}", | ||
| "publish": "docker push cnrsinist/${npm_package_name}:${npm_package_version}" | ||
| }, | ||
| "avoid-testing": false | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| { | ||
| "openapi": "3.0.0", | ||
| "info": { | ||
| "title": "rag-tools - Ws to generate embeddings and use those for rag", | ||
| "description": "Ws to generate embeddings and use those for rag", | ||
| "version": "0.3.0", | ||
| "termsOfService": "https://services.istex.fr/", | ||
| "contact": { | ||
| "name": "Inist-CNRS", | ||
| "url": "https://www.inist.fr/nous-contacter/" | ||
| } | ||
| }, | ||
| "servers": [ | ||
| { | ||
| "x-comment": "Will be automatically completed by the ezs server." | ||
| }, | ||
| { | ||
| "url": "http://vptdmservices.intra.inist.fr:49225/", | ||
| "description": "Latest version for production", | ||
| "#DISABLED#x-profil": "Standard" | ||
| } | ||
| ], | ||
| "tags": [ | ||
| { | ||
| "name": "rag-tools", | ||
| "description": "Ws to generate embeddings and use those for rag", | ||
| "externalDocs": { | ||
| "description": "Plus de documentation", | ||
| "url": "https://github.com/inist-cnrs/web-services/tree/main/services/rag-tools" | ||
| } | ||
| } | ||
| ] | ||
| } |
|
Luc-Ank marked this conversation as resolved.
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| [ | ||
| { | ||
| "id": "rag_test_001", | ||
| "value": { | ||
| "question": "Quelle est la plus grande planète du système solaire et quelles sont ses principales caractéristiques ?", | ||
| "documents": [ | ||
| "Jupiter est la plus grande planète du système solaire. C'est une planète gazeuse composée principalement d'hydrogène et d'hélium. Elle possède une grande tache rouge qui correspond à une immense tempête observée depuis plusieurs siècles.", | ||
| "Saturne est une planète gazeuse connue pour ses magnifiques anneaux composés principalement de glace et de roches. Elle est la sixième planète du système solaire en distance au Soleil.", | ||
| "La Terre est la troisième planète du système solaire en partant du Soleil. Elle possède une atmosphère riche en azote et en oxygène. C'est la seule planète connue où la vie existe actuellement." | ||
| ] | ||
| } | ||
| } | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| [ | ||
| { | ||
| "id": "reformulation_test_001", | ||
| "value": { | ||
| "question": "Et pour Saturne, c'est pareil ?", | ||
| "historique": [ | ||
| { | ||
| "role": "user", | ||
| "content": "Quelle est la plus grande planète du système solaire et quelles sont ses principales caractéristiques ?" | ||
| }, | ||
| { | ||
| "role": "assistant", | ||
| "content": "Jupiter est la plus grande planète du système solaire. C'est une planète gazeuse composée principalement d'hydrogène et d'hélium, et elle possède une grande tache rouge correspondant à une immense tempête observée depuis plusieurs siècles [Document 1]." | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| [ | ||
| { | ||
| "id": "doc_a82f91", | ||
| "value": "La Terre est la troisième planète du système solaire en partant du Soleil. Elle possède une atmosphère riche en azote et en oxygène. C'est la seule planète connue où la vie existe actuellement." | ||
| }, | ||
| { | ||
| "id": "doc_b71c42", | ||
| "value": "Mars est une planète rocheuse située après la Terre dans le système solaire. Elle est surnommée la planète rouge à cause de la présence d'oxyde de fer à sa surface. Mars possède deux petites lunes appelées Phobos et Déimos." | ||
| }, | ||
| { | ||
| "id": "doc_c94e35", | ||
| "value": "Jupiter est la plus grande planète du système solaire. C'est une planète gazeuse composée principalement d'hydrogène et d'hélium. Elle possède une grande tache rouge qui correspond à une immense tempête observée depuis plusieurs siècles." | ||
| }, | ||
| { | ||
| "id": "doc_d28f76", | ||
| "value": "Saturne est une planète gazeuse connue pour ses magnifiques anneaux composés principalement de glace et de roches. Elle est la sixième planète du système solaire en distance au Soleil." | ||
| }, | ||
| { | ||
| "id": "doc_e63a19", | ||
| "value": "Mercure est la planète la plus proche du Soleil. Elle est petite et rocheuse, et sa surface présente de nombreux cratères causés par des impacts d'astéroïdes." | ||
| }, | ||
| { | ||
| "id": "doc_f52b88", | ||
| "value": "Vénus est la deuxième planète du système solaire. Elle possède une atmosphère très dense composée principalement de dioxyde de carbone. Sa température de surface est extrêmement élevée." | ||
| } | ||
| ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🪳 : nitpick (non-blocking): On ne fixe pas la version de torch installée.
Ça peut poser un problème de reproductibilité si on reconstruit l'image plus tard.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Par ailleurs, on a une image de base
ezs-python-pytorch-serverqui installe déjà une version précise de torch.Certes, elle peut être un peu plus grosse, mais si jamais on l'optimise, rag-tools n'en profitera pas directement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pip install torchetsentence-transformerssans version contrevient à la règle projet (« Dependencies pinned with exact versions in Dockerfile ») suivie partout ailleurs (requests==2.32.5,sentence-transformers==2.2.2, etc.).Piège supplémentaire :
--extra-index-urln'exclut pas PyPI — pip peut résoudre une version plus récente depuis PyPI et récupérer le wheel CUDA que le commentaire cherche justement à éviter.Épinglez
torch==X.Y.Z+cpuavec--index-url(cf.bases/ezs-python-pytorch-server/Dockerfilequi fait exactement cela), et ajoutezrequestsexplicitement commedata-geonamesle fait — il n'arrive ici que transitivement viahuggingface_hub.