Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

marvin/README.md at main · PrefectHQ/marvin #965

Open
1 task
ShellLM opened this issue Jan 3, 2025 · 0 comments
Open
1 task

marvin/README.md at main · PrefectHQ/marvin #965

ShellLM opened this issue Jan 3, 2025 · 0 comments
Labels
AI-Agents Autonomous AI agents using LLMs AI-Chatbots Topics related to advanced chatbot platforms integrating multiple AI models ai-platform model hosts and APIs Algorithms Sorting, Learning or Classifying. All algorithms go here. Automation Automate the things finetuning Tools for finetuning of LLMs e.g. SFT or RLHF llm Large Language Models llm-applications Topics related to practical applications of Large Language Models in various fields multimodal-llm LLMs that combine modes such as text and image recognition. software-engineering Best practice for software engineering

Comments

@ShellLM
Copy link
Collaborator

ShellLM commented Jan 3, 2025

Marvin

The AI Engineering Toolkit

Hero Image

PyPI version
Docs
Twitter Follow
Gurubase

Marvin is a lightweight AI toolkit for building natural language interfaces that are reliable, scalable, and easy to trust.

Each of Marvin's tools is simple and self-documenting, using AI to solve common but complex challenges like entity extraction, classification, and generating synthetic data. Each tool is independent and incrementally adoptable, so you can use them on their own or in combination with any other library. Marvin is also multi-modal, supporting both image and audio generation as well as using images as inputs for extraction and classification.

Marvin is for developers who care more about using AI than building AI, and we are focused on creating an exceptional developer experience. Marvin users should feel empowered to bring tightly-scoped "AI magic" into any traditional software project with just a few extra lines of code.

Marvin aims to merge the best practices for building dependable, observable software with the best practices for building with generative AI into a single, easy-to-use library. It's a serious tool, but we hope you have fun with it.

Marvin is open-source, free to use, and made with 💙 by the team at Prefect.

Installation

Install the latest version with pip:

pip install marvin -U

To verify your installation, run marvin version in your terminal.

Tools

Marvin consists of a variety of useful tools, all designed to be used independently. Each one represents a common LLM use case, and packages that power into a simple, self-documenting interface.

General

🦾 Write custom AI-powered functions without source code

Text

🏷️ Classify text into categories
🔍 Extract structured entities from text
🪄 Transform text into structured data
Generate synthetic data from a schema

Images

🖼️ Create images from text or functions
📝 Describe images with natural language
🏷️ Classify images into categories
🔍 Extract structured entities from images
🪄 Transform images into structured data

Audio

💬 Generate speech from text or functions
✍️ Transcribe speech from recorded audio
🎙️ Record users continuously or as individual phrases

Video

🎙️ Record video continuously

Interaction

🤖 Chat with assistants and use custom tools
🧭 Build applications that manage persistent state

Quickstart

Here's a whirlwind tour of a few of Marvin's main features. For more information, check the docs!

🏷️ Classify text

Marvin can classify text using a set of labels:

import marvin

marvin.classify(
    "Marvin is so easy to use!",
    labels=["positive", "negative"],
)

#  "positive"

🔍 Extract structured entities

Marvin can extract structured entities from text:

import pydantic

class Location(pydantic.BaseModel):
    city: str
    state: str

marvin.extract("I moved from NY to CHI", target=Location)

# [
#     Location(city="New York", state="New York"),
#     Location(city="Chicago", state="Illinois")
# ]

Almost all Marvin functions can be given instructions for more control:

marvin.extract(
    "I paid $10 for 3 tacos and got a dollar and 25 cents back.",
    target=float,
    instructions="Only extract money"
)

#  [10.0, 1.25]

✨ Generate data

Marvin can generate synthetic data for you:

class Location(pydantic.BaseModel):
    city: str
    state: str

marvin.generate(
    n=4,
    target=Location,
    instructions="cities in the United States named after presidents"
)

# [
#     Location(city='Washington', state='District of Columbia'),
#     Location(city='Jackson', state='Mississippi'),
#     Location(city='Cleveland', state='Ohio'),
#     Location(city='Lincoln', state='Nebraska'),
# ]

🪄 Standardize text by casting to types

marvin.cast("one two three", list[int])
# [1, 2, 3]

@marvin.model
class Location(pydantic.BaseModel):
    city: str
    state: str

Location("The Big Apple")
# Location(city="New York", state="New York")

🦾 Build AI-powered functions

@marvin.fn
def sentiment(text: str) -> float:
    """
    Returns a sentiment score for `text`
    between -1 (negative) and 1 (positive).
    """

sentiment("I love working with Marvin!") # 0.8
sentiment("These examples could use some work...") # -0.2

🖼️ Generate images from text

marvin.paint("a simple cup of coffee, still warm")

Coffee Image

🔍 Converting images to data

marvin.classify(
    marvin.Image.from_path("docs/images/coffee.png"),
    labels=["drink", "food"],
)
# "drink"

Record, modify, and play audio

import marvin
import marvin.audio

# record the user
user_audio = marvin.audio.record_phrase()

# transcribe the text
user_text = marvin.transcribe(user_audio)

# cast the language to a more formal style
ai_text = marvin.cast(user_text, instructions='Make the language ridiculously formal')

# generate AI speech
ai_audio = marvin.speak(ai_text)

# play the result
ai_audio.play()

Get in touch!

💡 Feature idea? Share it in the #development channel in our Discord.

🐛 Found a bug? Feel free to open an issue.

👷 Feedback? Marvin is under active development, and we'd love to hear it.

Suggested labels

None

@ShellLM ShellLM added AI-Agents Autonomous AI agents using LLMs AI-Chatbots Topics related to advanced chatbot platforms integrating multiple AI models ai-platform model hosts and APIs Algorithms Sorting, Learning or Classifying. All algorithms go here. Automation Automate the things finetuning Tools for finetuning of LLMs e.g. SFT or RLHF llm Large Language Models llm-applications Topics related to practical applications of Large Language Models in various fields multimodal-llm LLMs that combine modes such as text and image recognition. software-engineering Best practice for software engineering labels Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AI-Agents Autonomous AI agents using LLMs AI-Chatbots Topics related to advanced chatbot platforms integrating multiple AI models ai-platform model hosts and APIs Algorithms Sorting, Learning or Classifying. All algorithms go here. Automation Automate the things finetuning Tools for finetuning of LLMs e.g. SFT or RLHF llm Large Language Models llm-applications Topics related to practical applications of Large Language Models in various fields multimodal-llm LLMs that combine modes such as text and image recognition. software-engineering Best practice for software engineering
Projects
None yet
Development

No branches or pull requests

1 participant