openai-cookbook icon indicating copy to clipboard operation
openai-cookbook copied to clipboard

Visualizing Embeddings with Atlas

Open AndriyMulyar opened this issue 2 years ago • 11 comments
trafficstars

An example notebook that showcases how to visualize and summarize OpenAI embeddings using Atlas

AndriyMulyar avatar Feb 22 '23 04:02 AndriyMulyar

@logankilpatrick Are their any changes needed to get this example notebook merged?

AndriyMulyar avatar Feb 22 '23 14:02 AndriyMulyar

Bumping this @logankilpatrick . Are their any changes needed to get this example notebook merged?

AndriyMulyar avatar Feb 27 '23 15:02 AndriyMulyar

If no one else gets to this, I'll commit to take a look next week. Apologies for the delays and thanks for your patience. We really do appreciate your contribution.

ted-at-openai avatar Mar 08 '23 06:03 ted-at-openai

Thank you @ted-at-openai !

AndriyMulyar avatar Mar 08 '23 18:03 AndriyMulyar

太垃圾

869351572 avatar Mar 14 '23 07:03 869351572

郭学胜到此一游

869351572 avatar Mar 14 '23 07:03 869351572

掉毛

869351572 avatar Mar 14 '23 07:03 869351572

guoxueshengCome here, a group of spicy chicken

869351572 avatar Mar 14 '23 07:03 869351572

Now that GPT-4 has launched, I now have time to get to this. Thanks for your patience over the past few weeks. :)

I tried running the example, but hit an error using the provided demo key:

2023-03-16 16:01:40.239 | INFO     | nomic.project:_create_project:932 - Creating project `futuristic-email` in organization `Atlas Demo`
---------------------------------------------------------------------------
Exception                                 Traceback (most recent call last)
[/var/folders/r4/x3kdvs816995fnnph2gdpwp40000gn/T/ipykernel_11410/3810895700.py](https://file+.vscode-resource.vscode-cdn.net/var/folders/r4/x3kdvs816995fnnph2gdpwp40000gn/T/ipykernel_11410/3810895700.py) in 
      4 
      5 data = df.to_dict('records')
----> 6 project = atlas.map_embeddings(embeddings=embeddings, data=data,
      7                                id_field='id',
      8                                colorable_fields=['Score'])

[~/.virtualenvs/openai/lib/python3.9/site-packages/nomic/atlas.py](https://file+.vscode-resource.vscode-cdn.net/Users/ted/code/openai-cookbook/examples/~/.virtualenvs/openai/lib/python3.9/site-packages/nomic/atlas.py) in map_embeddings(embeddings, data, id_field, name, description, is_public, colorable_fields, build_topic_model, topic_label_field, num_workers, organization_name, reset_project_if_exists, add_datums_if_exists, shard_size, projection_n_neighbors, projection_epochs, projection_spread)
     80         data = [{} for _ in range(len(embeddings))]
     81 
---> 82     project = AtlasProject(
     83         name=project_name,
     84         description=description,

[~/.virtualenvs/openai/lib/python3.9/site-packages/nomic/project.py](https://file+.vscode-resource.vscode-cdn.net/Users/ted/code/openai-cookbook/examples/~/.virtualenvs/openai/lib/python3.9/site-packages/nomic/project.py) in __init__(self, name, description, unique_id_field, modality, organization_name, is_public, project_id, reset_project_if_exists, add_datums_if_exists)
    866                 raise ValueError("You must specify a modality when creating a new project.")
    867 
--> 868             project_id = self._create_project(
    869                 project_name=name,
    870                 description=description,

[~/.virtualenvs/openai/lib/python3.9/site-packages/nomic/project.py](https://file+.vscode-resource.vscode-cdn.net/Users/ted/code/openai-cookbook/examples/~/.virtualenvs/openai/lib/python3.9/site-packages/nomic/project.py) in _create_project(self, project_name, description, unique_id_field, modality, organization_name, is_public)
    945         )
    946         if response.status_code != 201:
--> 947             raise Exception(f"Failed to create project: {response.json()}")
    948 
    949         return response.json()['project_id']

Exception: Failed to create project: {'detail': 'To many projects exist. Delete projects to create a new one.'}

Is there a way to fix this so folks don't hit an error when they run it for the first time?

ted-at-openai avatar Mar 16 '23 23:03 ted-at-openai

Should be fixed now!

AndriyMulyar avatar Mar 16 '23 23:03 AndriyMulyar

@ted-at-openai Looking forward to your review!

AndriyMulyar avatar Mar 17 '23 20:03 AndriyMulyar

Awesome, it works now.

ted-at-openai avatar Mar 28 '23 23:03 ted-at-openai

Looks great and I'm happy to merge. Can I ask for one small change before merging:

  • Change name to Visualizing_embeddings_with_Atlas.ipynb

The benefit of this name is that this way all of the embedding visualization examples will go together when listed alphabetically.

ted-at-openai avatar Mar 28 '23 23:03 ted-at-openai

Renamed!

AndriyMulyar avatar Mar 28 '23 23:03 AndriyMulyar

Sweet. Merging now. Thanks for your patience with us (me).

ted-at-openai avatar Mar 28 '23 23:03 ted-at-openai