Skip to content

Commit

Permalink
Merge pull request #158 from enoch3712/153-how-to-implement-groq-llm
Browse files Browse the repository at this point in the history
Groq documentation added
  • Loading branch information
enoch3712 authored Dec 28, 2024
2 parents a9c222c + 4be00dd commit bded4e1
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions docs/examples/groq-processing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Processing Documents with Groq

> ⚠️ **Warning**: Vision-based processing may not be available with Groq models. For image or document processing that requires vision capabilities, consider using other providers like Google Document AI, Azure Document Intelligence, or AWS Textract.
This guide demonstrates how to process documents using Groq's powerful LLMs.

## Basic Setup

Here's a basic example of document extraction using Groq:

```python
from extract_thinker import Extractor
from extract_thinker.document_loader.document_loader_pypdf import DocumentLoaderPyPdf
from typing import List
from pydantic import Field

class InvoiceContract(Contract):
lines: List[LineItem] = Field("List of line items in the invoice")

# Initialize extractor with PyPDF loader
extractor = Extractor()
extractor.load_document_loader(DocumentLoaderPyPdf())

# Configure Groq
extractor.load_llm("groq/llama-3.2-11b-vision-preview")

# Process document
result = extractor.extract("invoice.pdf", InvoiceContract)
```

## Classification Example

You can also use Groq for document classification:

```python
from extract_thinker import Process
from extract_thinker.models.classification import Classification

# Setup process
process = Process()
process.add_classify_extractor([[extractor]])

# Define classifications
classifications = [
Classification(
name="Invoice",
description="This is an invoice document",
contract=InvoiceContract
),
Classification(
name="Driver License",
description="This is a driver license document",
contract=DriverLicense
)
]

# Classify document
result = process.classify("document.pdf", classifications)
```

## Benefits

1. **High Performance**
- Fast inference times
- High-quality results
- State-of-the-art language models

0 comments on commit bded4e1

Please sign in to comment.