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

Fix image paths in tutorial docs #764

Merged
merged 4 commits into from
Jan 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 12 additions & 15 deletions docs/welcome/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ toc_depth: 3
---
# Tutorial

![](/docs/assets/images/heroes/dont_panic.png){ width=500 }
![](/assets/images/heroes/dont_panic.png)


## Installing Marvin

Expand All @@ -15,7 +16,7 @@ Before we can start, you'll need to [install Marvin](installation.md). Come back

Marvin uses OpenAI models to power all of its tools. In order to use Marvin, you'll need an OpenAI API key.

You can create an API key [on the OpenAI platform ](https://platform.openai.com/api-keys). Once you've created it, set it as an environment variable called `OPENAI_API_KEY` (for any application on your machine to use) or `MARVIN_OPENAI_API_KEY` (if you only want Marvin to use it). In addition to setting it in your terminal, you can also write the variable to a dotenv file at `~/.marvin/.env`.
You can create an API key [on the OpenAI platform](https://platform.openai.com/api-keys). Once you've created it, set it as an environment variable called `OPENAI_API_KEY` (for any application on your machine to use) or `MARVIN_OPENAI_API_KEY` (if you only want Marvin to use it). In addition to setting it in your terminal, you can also write the variable to a dotenv file at `~/.marvin/.env`.

For quick use, you can also pass your API key directly to Marvin at runtime. We do **NOT** recommend this for production:

Expand All @@ -32,7 +33,6 @@ Marvin has a variety of tools that let you use LLMs to solve common but complex

Classification is one of Marvin's most straightforward features. Given some text and a list of labels, Marvin will choose the label that best fits the text. The `classify` function is great for tasks like sentiment analysis, intent classification, routing, and more.


!!! Example "First steps: true/false"

Here is the simplest possible classification example, mapping the word "yes" to the boolean values `True` or `False`:
Expand All @@ -48,9 +48,8 @@ Classification is one of Marvin's most straightforward features. Given some text
assert result is True
```


!!! Example "A more practical example: sentiment"

A more useful example is to classify text as one of several categories, provided as a list of labels. In this example, we build a basic sentiment classifier for any text:

```python
Expand All @@ -72,11 +71,10 @@ This is a great example of how all Marvin tools should feel. Historically, class
!!! tip "Structured labels"
For the `classify` function, you can supply labels as a `list` of labels, a `bool` type, an `Enum` class, or a `Literal` type. This gives you many options for returning structured (non-string) labels.

### 🪄 Transformation
### 🪄 Transformation

Classification maps text to a single label, but what if you want to convert text to a more structured form? Marvin's `cast` function lets you do just that. Given some text and a target type, Marvin will return a structured representation of the text.


!!! example "Standardization"

Suppose you ran a survey and one of the questions asked where people live. Marvin can convert their freeform responses to a structured `Location` type:
Expand Down Expand Up @@ -174,7 +172,7 @@ The `extract` function can take a target type, just like `cast`. This lets you e
Location(city="Los Angeles", state="California"),
]
```

### ✨ Generation

So far, we've used Marvin to take existing text and convert it to a more structured or modified form that preserves its content but makes it easier to work with. Marvin can also generate synthetic data from a schema or instructions. This is incredibly useful for ideation, testing, data augmentation, populating databases, and more.
Expand Down Expand Up @@ -212,7 +210,6 @@ Let's use Marvin's `generate` function to produce synthetic data. The `generate`
]
```


In addition to structured types, Marvin can generate new text from instructions.

!!! Example "Character names"
Expand Down Expand Up @@ -279,7 +276,7 @@ Marvin is multi-modal! In addition to text, Marvin can also work with images. Mo

### 🎨 Generation

Marvin gives you easy access to the DALL-E 3 image generation model. This model can generate images from text descriptions
Marvin gives you easy access to the DALL-E 3 image generation model. This model can generate images from text descriptions.

!!! Example "Generating images"

Expand All @@ -290,8 +287,9 @@ Marvin gives you easy access to the DALL-E 3 image generation model. This model
```

!!! success "Result"
( Note: your results may vary)

![](assets/images/docs/images/coffee.png)
![A cup off coffee](/assets/images/docs/images/coffee.png)

### 📝 Captioning

Expand Down Expand Up @@ -319,20 +317,19 @@ If you've already got an image, you can convert it to text using the `caption` f

### 🚀 Transformation, classification, and extraction

Now that you've seen that Marvin can turn images into text, you're probably wondering if we can use that text with the `cast`, `extract`, and `classify` functions we saw earlier. The answer is yes -- but we can do even better.
Now that you've seen that Marvin can turn images into text, you're probably wondering if we can use that text with the `cast`, `extract`, and `classify` functions we saw earlier. The answer is yes -- but we can do even better.

If you caption an image, the resulting text might not capture the details that are most relevant to the text processing task you want to perform. For example, if you want to classify the breed of dog in an image, you're going to need very specific information that a generic caption might not provide.

Therefore, Marvin has beta versions of `cast`, `extract`, and `classify` that accept images as inputs. Instead of generating generic captions, these functions process the image in a way that is most conducive to the task at hand.

These functions are available under `marvin.beta` and work identically to their text-only counterparts except that they can take images as well as text inputs.


!!! example "Identifying dog breeds in an image"

Let's identify the breed of each dog in this image by using the beta `extract` function.

![](https://images.unsplash.com/photo-1548199973-03cce0bbc87b?q=80&w=2969&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D)
![Two dogs moving toward the camera](https://images.unsplash.com/photo-1548199973-03cce0bbc87b?q=80&w=2969&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D)

```python
import marvin
Expand All @@ -349,7 +346,7 @@ These functions are available under `marvin.beta` and work identically to their

## Grab your towel

We hope this tutorial has given you a taste of what Marvin can do. There's a lot more to explore, including tools for interactive use cases (like chatbots and applications), audio generation, and more.
We hope this tutorial has given you a taste of what Marvin can do. There's a lot more to explore, including tools for interactive use cases (like chatbots and applications), audio generation, and more.

To learn more, please explore the docs or say hi in our [Discord community](https://discord.gg/Kgw4HpcuYG)!

Expand Down