Merged
Conversation
cgoudet
approved these changes
Mar 8, 2026
Collaborator
cgoudet
left a comment
There was a problem hiding this comment.
Merci! Super boulot!
Peux tu te mettre en contact avec Hugo qui devait intégrer le type vector dans la db. Comme tu le fais ici il peut passer à autre chose.
|
|
||
| model = _get_model() | ||
| for batch in _iter_batches(persisted_chunks, EMBED_BATCH_SIZE): | ||
| texts = [f"{PASSAGE_PREFIX}{chunk.content}" for chunk in batch] |
Collaborator
There was a problem hiding this comment.
Pourquoi tu ajoutes ce préfixe au texte?
eu_fact_force/ingestion/embedding.py
Outdated
| for chunk, vector in zip(batch, vectors): | ||
| chunk.embedding = vector.tolist() if hasattr(vector, "tolist") else list(vector) | ||
|
|
||
| DocumentChunk.objects.bulk_update(persisted_chunks, ["embedding"]) |
Collaborator
There was a problem hiding this comment.
Quitte à faire un batch autant faire l'update du batch à chaque fois non?
tests/ingestion/test_embedding.py
Outdated
| @pytest.mark.django_db | ||
| def test_add_embeddings_updates_persisted_chunks(monkeypatch): | ||
| source = SourceFile.objects.create(doi="x", s3_key="k", status=SourceFile.Status.STORED) | ||
| chunk_1 = DocumentChunk.objects.create(source_file=source, content="alpha", order=1) |
Collaborator
There was a problem hiding this comment.
Pour être un poil plus propre on pourrait partir sur des Factory pour générer les objets à tester.
|
|
||
| embedding_module.add_embeddings([persisted, empty_chunk, unsaved_chunk]) | ||
|
|
||
| persisted.refresh_from_db() |
Collaborator
There was a problem hiding this comment.
Je dirais ici qu'il faut récupérer toute la base pour voir si empty et unsaved n'ont pas été sauvegardés justement.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds embedding persistence on top of the Docling+chunking pipeline baseline.
Changes
add_embeddings()now usesintfloat/multilingual-e5-basepassage:)batch_size=32)bulk_updateTest plan
pytest tests/ingestion/test_embedding.py -qpytest tests/ingestion/test_chunking.py tests/ingestion/test_run_pipeline.py -q