Skip to main content

Objects

An Object is versioned, serializable data. Weave automatically versions objects when they change and creates an immutable history. Objects include:
  • Datasets: Collections of examples for evaluation
  • Models: Configurations and parameters for your LLM logic
  • Prompts: Versioned prompt templates
dataset = weave.Dataset(
    name="test-cases",
    rows=[
        {"input": "What is 2+2?", "expected": "4"},
        {"input": "What is the capital of France?", "expected": "Paris"},
    ]
)
weave.publish(dataset)

Publishing an object

Weave’s serialization layer saves and versions objects.
import weave
weave.init("your-team-name/your-project-name")
# Save a list, giving it the name 'cat-names'
weave.publish(['felix', 'jimbo', 'billie'], 'cat-names')
When you save an object with a name, Weave creates the first version of that object if it does not exist.

Get an object back

weave.publish returns a Ref. You can call .get() on any Ref to get the object back.You can construct a ref and then fetch the object back.
weave.init("your-team-name/your-project-name")
cat_names = weave.ref('cat-names').get()

Delete an object

To delete a version of an object, call .delete() on the object ref.
weave.init("your-team-name/your-project-name")
cat_names_ref = weave.ref('cat-names:v1')
cat_names_ref.delete()
Accessing a deleted object returns an error. Resolving an object that has a reference to a deleted object returns a DeletedRef in place of the deleted object.

Constructing object refs

In Weave, a fully qualified object ref URI looks like this:
weave:///<your-team-name>/<your-project-name>/object/<object_name>:<object_version>
  • your-team-name: W&B entity (username or team name)
  • your-project-name: W&B project
  • object_name: object name
  • object_version: either a version hash, a string like v0 or v1, or an alias like :latest. All objects have the :latest alias.
You can construct refs with a few different styles:
  • weave.ref(<name>): Retrieves the :latest version of an object. Requires calling weave.init(...).
  • weave.ref(<name>:<version>): Retrieves the specified version of an object. Requires calling weave.init(...).
  • weave.ref(<fully_qualified_ref_uri>): Retrieves the object located at the specified fully qualified object ref URI. Does not require calling weave.init.