Skip to main content

Respan instrumentation plugin for Hugging Face Transformers

Project description

respan-instrumentation-huggingface

Respan instrumentation plugin for Hugging Face Transformers.

This package wraps the upstream opentelemetry-instrumentation-transformers instrumentor and adds a small Respan contract processor so TextGenerationPipeline.__call__ spans export with canonical Respan fields.

Installation

pip install respan-ai respan-instrumentation-huggingface

Usage

from respan import Respan, workflow
from respan_instrumentation_huggingface import HuggingFaceInstrumentor
from transformers import pipeline

respan = Respan(
    app_name="huggingface-text-generation",
    instrumentations=[HuggingFaceInstrumentor()],
)


@workflow(name="huggingface_text_generation")
def run_generation():
    generator = pipeline(
        "text-generation",
        model="sshleifer/tiny-gpt2",
    )
    return generator(
        "Tracing helps teams",
        max_length=30,
        temperature=0.7,
        top_p=0.9,
    )


try:
    print(run_generation())
finally:
    respan.flush()
    respan.shutdown()

Set TRACELOOP_TRACE_CONTENT=false to suppress prompt and completion text in span attributes while still exporting model and request metadata.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

respan_instrumentation_huggingface-0.1.0.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file respan_instrumentation_huggingface-0.1.0.tar.gz.

File metadata

File hashes

Hashes for respan_instrumentation_huggingface-0.1.0.tar.gz
Algorithm Hash digest
SHA256 42bb77a3c4fc385ed8e2a88eb32824cf88ef3cb305cb392a72ed05bf752915a4
MD5 acce4f5e3b82923efe494fb651019e9b
BLAKE2b-256 a303589a277f5d3f65d2c99c6d571f2db0364a78e3630a4f394882d8415fdbff

See more details on using hashes here.

File details

Details for the file respan_instrumentation_huggingface-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for respan_instrumentation_huggingface-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 78fc32d272a470f3c6a118396396b70b239e9d8242e0c1241c1141c7d9cd0956
MD5 bfdb3c090e063cf224cf83402139f74c
BLAKE2b-256 cb2f22be6b37e691d006b3d6e48b90caee0871be17ccea957521f6a5edd94ce5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page