feat(transformers): Add HuggingFace Transformers integration - #676
Open
Abhijeet Prasad (AbhiPrasad) wants to merge 2 commits into
Open
feat(transformers): Add HuggingFace Transformers integration#676Abhijeet Prasad (AbhiPrasad) wants to merge 2 commits into
Abhijeet Prasad (AbhiPrasad) wants to merge 2 commits into
Conversation
Add integration-API instrumentation for supported local Transformers
pipelines, including normalized chat-style input/output, compact tensor shape
output, pipeline metadata, error spans, and transformers-auto provenance.
Direct integration setup:
```python
from braintrust.integrations.transformers import setup_transformers
from transformers import pipeline
setup_transformers()
generator = pipeline("text-generation", model="my-model")
```
Automatic instrumentation:
```python
import braintrust
braintrust.auto_instrument(transformers=True)
from transformers import pipeline
generator = pipeline("text-generation", model="my-model")
```
Manual instrumentation:
```python
from braintrust.integrations.transformers import wrap_transformers
from transformers import pipeline
generator = wrap_transformers(
pipeline("text-generation", model="my-model")
)
```
Example trace waterfall:
```text
time ------------------------------------------------------------->
application request [task] =====================
huggingface.transformers.text_generation =====
huggingface.transformers.summarization ======
huggingface.transformers.feature_extraction ====
```
Exercise real tiny CPU models across the supported Python/Transformers
matrix, using CPU-only PyTorch and a shared Hugging Face model cache in CI.
Preserve explicit uv indexes when installing exported dependency groups so the Transformers sessions can resolve the locked CPU-only PyTorch wheel.
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.
resolves #517
Add integration-API instrumentation for supported local Transformers pipelines, including normalized chat-style input/output, compact tensor shape output, pipeline metadata, error spans, and transformers-auto provenance.
Direct integration setup:
Automatic instrumentation:
Manual instrumentation:
Example trace waterfall:
Exercise real tiny CPU models across the supported Python/Transformers matrix, using CPU-only PyTorch and a shared Hugging Face model cache in CI.