Skip to content

Add CommunityToolkit.DataIngestion.VisionLMOcr (IOcrClient over vision IChatClient) (draft)#15

Closed
luisquintanilla wants to merge 8 commits into
CommunityToolkit:mainfrom
luisquintanilla:feature/vislm-ocr-client
Closed

Add CommunityToolkit.DataIngestion.VisionLMOcr (IOcrClient over vision IChatClient) (draft)#15
luisquintanilla wants to merge 8 commits into
CommunityToolkit:mainfrom
luisquintanilla:feature/vislm-ocr-client

Conversation

@luisquintanilla

Copy link
Copy Markdown

Summary

Adds CommunityToolkit.DataIngestion.VisionLMOcr — a provider-neutral IOcrClient backed by
any vision-capable Microsoft.Extensions.AI.IChatClient. It relocates the vision-LM OCR
prompt/request logic out of the PdfPig VisionOcrEnricher and behind the IOcrClient seam, so a
vision LM becomes one swappable OCR provider (alongside Mistral OCR / Azure DI).

Closes #13.

⚠️ Review scope (this PR is stacked on #10)

main has no MEDI scaffolding yet — it lives on the feature/data-ingestion branch (PR #10). This
package is a satellite of CommunityToolkit.DataIngestion, so it is built on top of #10. Until
#10 merges to main, this PR's diff also shows #10's files; please review only the new files
below
(everything else is #10 and drops out automatically once #10 lands):

  • MEDI/src/DataIngestion.VisionLMOcr/DataIngestion.VisionLMOcr.csproj
  • MEDI/src/DataIngestion.VisionLMOcr/VisionLMOcrClient.cs
  • MEDI/src/DataIngestion.VisionLMOcr/VisionLMOcrOptions.cs
  • MEDI/src/DataIngestion.VisionLMOcr/VisionLMOcrPrompts.cs
  • MEDI/src/DataIngestion.VisionLMOcr/VisionLMOcrServiceCollectionExtensions.cs
  • MEDI/test/DataIngestion.VisionLMOcr.UnitTests/DataIngestion.VisionLMOcr.UnitTests.csproj
  • MEDI/test/DataIngestion.VisionLMOcr.UnitTests/VisionLMOcrClientTests.cs
  • CommunityToolkit.AI.slnx (2 project entries)

I'll rebase/retarget onto main once #10 merges, collapsing the diff to just these files.

Notes

  • VENDORS the unpublished IOcrClient shape (dotnet/extensions #7588). Un-vendor and reference
    Microsoft.Extensions.DataIngestion.Abstractions when #7588 ships.
  • Reader/consumer neutrality preserved: this is one IOcrClient provider; the abstraction stays in
    dotnet/extensions, concrete providers live here.
  • net10.0;net8.0, 6/6 unit tests pass on both TFMs (fake IChatClient, no network).

Validation

dotnet build MEDI/src/DataIngestion.VisionLMOcr/DataIngestion.VisionLMOcr.csproj -p:EnforceCodeStyleInBuild=false -p:RunAnalyzers=false
dotnet test  MEDI/test/DataIngestion.VisionLMOcr.UnitTests/DataIngestion.VisionLMOcr.UnitTests.csproj -p:EnforceCodeStyleInBuild=false -p:RunAnalyzers=false

luisquintanilla and others added 8 commits April 27, 2026 20:12
… DataIngestion)

Port intelligent PDF ingestion packages from luisquintanilla/PdfPig
(feature/intelligent-pdf-ingestion branch, PRs #1 and #2) into the
AI Community Toolkit as a new MEDI top-level feature area.

New packages:
- CommunityToolkit.DocumentProcessing.PdfPig.OnnxLayoutAnalysis
  ONNX-based layout detection (RT-DETR, configurable models, image
  preprocessing, NMS) implementing PdfPig IPageSegmenter
- CommunityToolkit.DocumentProcessing.PdfPig.DataIngestion
  MEDI bridge with vision LLM enrichers (OCR, table extraction,
  contextual chunking) for PDF document ingestion

Infrastructure:
- MEDI/ directory structure following MEVD pattern
- Directory.Build.props for src and test
- Central package management updates
- MEDI.slnf solution filter
- medi.yml CI workflow
- nuget.config with source mapping for dotnet-public feed

Test results: 216 total (213 passed, 3 skipped for missing ONNX model)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Port retrieval processors from MEDIExtensions to CommunityToolkit:
- DataRetrieval: MultiQueryExpander, HydeQueryTransformer, AdaptiveRouter,
  CragValidator, LlmReranker, TreeSearchRetriever, SelfRagOrchestrator,
  SpeculativeRagOrchestrator, RetrievalPipelineBuilder, DI extensions
- DataRetrieval.OnnxReranker: CrossEncoderReranker with ONNX inference,
  TextPairTokenizer, TokenizerFactory (BERT/BPE/SentencePiece support)

Both packages target net10.0;net8.0, build with 0 errors/0 warnings.
Added local NuGet source for Microsoft.Extensions.DataRetrieval packages.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Adds a terminal method to RetrievalPipelineBuilder that registers
a VectorStoreRetriever<TKey,TRecord> as IRetriever in DI. This
enables the builder pattern: services.AddRetrievalPipeline(b => {
    b.AddQueryProcessor(...); }).AsRetriever<K,R>(...);

Also exposes Services property on builder so the terminal can
register the retriever in the service collection.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Port 4 LLM-powered ingestion chunk processors from MEDIExtensions:
- EntityExtractionProcessor: NER via LLM (people, orgs, tech, versions)
- TopicClassificationProcessor: Configurable taxonomy classification
- HypotheticalQueryProcessor: Reverse HyDE question generation
- TreeIndexProcessor: RAPTOR-style tree index (leaf/branch/root summaries)

Includes:
- IngestionPipelineBuilder<T> with fluent builder extensions
- DataIngestionServiceCollectionExtensions for DI registration
- MetadataKeys constants (FDG compliance)
- Optional ILogger on all processors (FDG compliance)
- JsonDefaults internal utility

Implements IngestionChunkProcessor<string> from the stable
Microsoft.Extensions.DataIngestion package.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Port retrieval processor unit tests from MEDIExtensions with namespace
remapping. Covers: MultiQueryExpander, LlmReranker, HydeQueryTransformer,
CragValidator, AdaptiveRouter, SelfRagOrchestrator, SpeculativeRagOrchestrator,
TreeSearchRetriever.

Includes test utilities (TestChatClient, TestVectorStoreCollection) for
deterministic LLM-free testing.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Port ingestion processor unit tests covering: EntityExtraction,
TopicClassification, HypotheticalQuery, TreeIndex processors.

All tests use TestChatClient for deterministic LLM-free execution.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@luisquintanilla luisquintanilla closed this by deleting the head repository Jul 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add VisionLMOcrClient: an IOcrClient backed by a vision-capable IChatClient

2 participants