# Create a Model

## Creating a Model

A Model represents a machine learning model. Each Model has a type. Currently Merlin supports both standard model types (PyTorch, SKLearn, Tensorflow, and XGBoost) and user-defined models (PyFunc model).

Merlin also supports custom models. More info can be found here:

{% content-ref url="/pages/6kwE95Lt6Vke46x0PTxu" %}
[Custom Model](/user-guides/01_getting_started/02_creating_a_model/01_custom_model.md)
{% endcontent-ref %}

Conceptually, a Model in Merlin is similar to a class in programming languages. To instantiate a Model, you’ll have to create a [Model Version](#creating-a-model-version).

`merlin.set_model(<model_name>, <model_type>)` will set the active model to the name given by parameter. If the Model with given name is not found, a new Model will be created.

{% code title="model\_creation.py" overflow="wrap" lineNumbers="true" %}

```python
import merlin
from merlin.model import ModelType

merlin.set_model("tensorflow-sample", ModelType.TENSORFLOW)
```

{% endcode %}

## Creating a Model Version

A Model Version represents a snapshot of A particular Model iteration. A Model Version might contain artifacts which are deployable to Merlin. You'll also be able to attach information such as metrics and tags to a given Model Version.

{% code title="model\_version\_creation.py" overflow="wrap" lineNumbers="true" %}

```python
with merlin.new_model_version() as v:
    merlin.log_metric("metric", 0.1)
    merlin.log_param("param", "value")
    merlin.set_tag("tag", "value")

    merlin.log_model(model_dir='tensorflow-sample')
```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.caraml.dev/user-guides/01_getting_started/02_creating_a_model.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
