{"id":7054,"date":"2023-08-08T11:46:11","date_gmt":"2023-08-08T19:46:11","guid":{"rendered":"https:\/\/live-cometml.pantheonsite.io\/?p=7054"},"modified":"2025-04-24T17:14:57","modified_gmt":"2025-04-24T17:14:57","slug":"nlp-for-text-to-image-generators-prompt-analysis-part-1","status":"publish","type":"post","link":"https:\/\/www.comet.com\/site\/blog\/nlp-for-text-to-image-generators-prompt-analysis-part-1\/","title":{"rendered":"NLP for Text-to-Image Generators: Prompt Analysis [Part 1]"},"content":{"rendered":"\n<link rel=\"canonical\" href=\"https:\/\/www.comet.com\/site\/blog\/nlp-for-text-to-image-generators-prompt-analysis-part-1\">\n\n\n\n<div class=\"fh fi fj fk fl\">\n<div class=\"ab ca\">\n<div class=\"ch bg et eu ev ew\">\n<figure class=\"mi mj mk ml mm mn mf mg paragraph-image\">\n<div class=\"mo mp eb mq bg mr\" tabindex=\"0\" role=\"button\">\n<figure><img loading=\"lazy\" decoding=\"async\" class=\"bg ms mt c\" role=\"presentation\" src=\"https:\/\/miro.medium.com\/v2\/resize:fit:700\/1*uY2VNRs34bfnz0DfSOeSfw.jpeg\" alt=\"\" width=\"700\" height=\"700\"><\/figure><div class=\"mf mg mh\"><picture><\/picture><\/div>\n<\/div><figcaption class=\"mu mv mw mf mg mx my be b bf z dv\" data-selectable-paragraph=\"\">Art by DALL-E 2<\/figcaption><\/figure>\n<p id=\"4b36\" class=\"pw-post-body-paragraph mz na fo be b gm nb nc nd gp ne nf ng nh ni nj nk nl nm nn no np nq nr ns nt fh bj\" data-selectable-paragraph=\"\">Text-to-image generators are currently a red hot topic in the field of AI art. With them, a user can provide text describing the artwork they\u2019d like to output, and the machine generates different variations of this image (sometimes in less than a minute!). Deep learning powers this technology, which helps anyone without design skills create artwork with just their sheer imagination. These AI systems have been trained using millions of images, along with their captions.<\/p>\n<p id=\"50b2\" class=\"pw-post-body-paragraph mz na fo be b gm nb nc nd gp ne nf ng nh ni nj nk nl nm nn no np nq nr ns nt fh bj\" data-selectable-paragraph=\"\">Some companies have trained their own AI \u201cartists\u201d and made them publicly available for people to use. Examples of such products include:<\/p>\n<ul class=\"\">\n<li id=\"3526\" class=\"mz na fo be b gm nb nc nd gp ne nf ng nu ni nj nk nv nm nn no nw nq nr ns nt nx ny nz bj\" data-selectable-paragraph=\"\"><a class=\"af oa\" href=\"https:\/\/openai.com\/dall-e-2\/\" target=\"_blank\" rel=\"noopener ugc nofollow\">DALL-E 2 by OpenAI<\/a> is an AI system that pioneered this field. It is currently in public closed beta and you need to purchase credits to use it.<\/li>\n<li id=\"b980\" class=\"mz na fo be b gm ob nc nd gp oc nf ng nu od nj nk nv oe nn no nw of nr ns nt nx ny nz bj\" data-selectable-paragraph=\"\"><a class=\"af oa\" href=\"https:\/\/www.midjourney.com\/home\/\" target=\"_blank\" rel=\"noopener ugc nofollow\">Midjourney <\/a>is an independent research lab that offers an AI program that creates images using textual descriptions. It is integrated with discord via a bot.<\/li>\n<li id=\"2599\" class=\"mz na fo be b gm ob nc nd gp oc nf ng nu od nj nk nv oe nn no nw of nr ns nt nx ny nz bj\" data-selectable-paragraph=\"\"><a class=\"af oa\" href=\"https:\/\/creator.nightcafe.studio\/stable-diffusion-image-generator\" target=\"_blank\" rel=\"noopener ugc nofollow\">Stable diffusion<\/a> is a latent text-to-image <a class=\"af oa\" href=\"https:\/\/www.assemblyai.com\/blog\/diffusion-models-for-machine-learning-introduction\/#:~:text=Diffusion%20Models%20are%20generative%20models%2C%20meaning%20that%20they%20are%20used,by%20reversing%20this%20noising%20process.\" target=\"_blank\" rel=\"noopener ugc nofollow\">diffusion model<\/a> capable of generating photo-realistic images, given any text input. Created by <a class=\"af oa\" href=\"https:\/\/stability.ai\/\" target=\"_blank\" rel=\"noopener ugc nofollow\">Stability AI<\/a>, they open-sourced a <a class=\"af oa\" href=\"https:\/\/github.com\/CompVis\/stable-diffusion\" target=\"_blank\" rel=\"noopener ugc nofollow\">GitHub repository<\/a> that has pre-trained models.<\/li>\n<\/ul>\n<p id=\"ae13\" class=\"pw-post-body-paragraph mz na fo be b gm nb nc nd gp ne nf ng nh ni nj nk nl nm nn no np nq nr ns nt fh bj\" data-selectable-paragraph=\"\">The main work involved in using these AI systems is coming up with textual descriptions of visuals you\u2019d like to create. These descriptions, called \u201cprompts,\u201d can be as vague or as detailed as you\u2019d like. The more specific your prompt is, the higher the level of fidelity of the image generated. The use of specific keywords can help to boost the quality of your image. For your reference, check out the <a class=\"af oa\" href=\"https:\/\/dallery.gallery\/the-dalle-2-prompt-book\/\" target=\"_blank\" rel=\"noopener ugc nofollow\">Dalle-2 Prompt Book<\/a> to get started with creating quality prompts.<\/p>\n<p id=\"98f1\" class=\"pw-post-body-paragraph mz na fo be b gm nb nc nd gp ne nf ng nh ni nj nk nl nm nn no np nq nr ns nt fh bj\" data-selectable-paragraph=\"\">In this article, you are going to analyze a dataset of 200K+ prompts created by Midjourney users. This dataset is available in <a class=\"af oa\" href=\"https:\/\/huggingface.co\/datasets\/succinctly\/midjourney-prompts\/viewer\/succinctly--midjourney-prompts\/validation\" target=\"_blank\" rel=\"noopener ugc nofollow\">HuggingFace<\/a> and you are going to use it to:<\/p>\n<ul class=\"\">\n<li id=\"10b9\" class=\"mz na fo be b gm nb nc nd gp ne nf ng nu ni nj nk nv nm nn no nw nq nr ns nt nx ny nz bj\" data-selectable-paragraph=\"\">Create and visualize word embeddings;<\/li>\n<li id=\"1c08\" class=\"mz na fo be b gm ob nc nd gp oc nf ng nu od nj nk nv oe nn no nw of nr ns nt nx ny nz bj\" data-selectable-paragraph=\"\">Perform a semantic search that will help you find similar prompts;<\/li>\n<li id=\"2804\" class=\"mz na fo be b gm ob nc nd gp oc nf ng nu od nj nk nv oe nn no nw of nr ns nt nx ny nz bj\" data-selectable-paragraph=\"\">Explore topics using clustering algorithms and visualize the keywords in each cluster.<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n<div class=\"fh fi fj fk fl\">\n<div class=\"ab ca\">\n<div class=\"ch bg et eu ev ew\"><\/div>\n<\/div>\n<\/div>\n\n\n\n<div class=\"fh fi fj fk fl\">\n<div class=\"ab ca\">\n<div class=\"ch bg et eu ev ew\">\n<h1 id=\"32cc\" class=\"oy oz fo be pa pb pc go pd pe pf gr pg ph pi pj pk pl pm pn po pp pq pr ps pt bj\" data-selectable-paragraph=\"\"><strong class=\"al\">Prerequisites<\/strong><\/h1>\n<p id=\"a6c6\" class=\"pw-post-body-paragraph mz na fo be b gm pu nc nd gp pv nf ng nh pw nj nk nl px nn no np py nr ns nt fh bj\" data-selectable-paragraph=\"\">You will need to have python 3.6+ installed in your development environment in order to follow along with this hands-on tutorial. In addition, you need to create an account for <a class=\"af oa\" href=\"https:\/\/os.cohere.ai\/login\" target=\"_blank\" rel=\"noopener ugc nofollow\">Cohere<\/a>.<\/p>\n<blockquote class=\"pz qa qb\"><p id=\"05b5\" class=\"mz na qc be b gm nb nc nd gp ne nf ng nu ni nj nk nv nm nn no nw nq nr ns nt fh bj\" data-selectable-paragraph=\"\">Cohere is a platform that provides access to advanced large language models and NLP tools through one easy-to-use API. The platform offers free credits that you can use to experiment with your NLP projects.<\/p><\/blockquote>\n<p id=\"a27f\" class=\"pw-post-body-paragraph mz na fo be b gm nb nc nd gp ne nf ng nh ni nj nk nl nm nn no np nq nr ns nt fh bj\" data-selectable-paragraph=\"\">Install the following python modules before getting started<\/p>\n<pre class=\"mi mj mk ml mm qd qe qf qg ax qh bj\"><span id=\"023e\" class=\"qi oz fo qe b ia qj qk l iq ql\" data-selectable-paragraph=\"\">pip install datasets cohere altair numpy pandas sklearn wordcloud matplotlib<\/span><\/pre>\n<h1 id=\"fb9e\" class=\"oy oz fo be pa pb qm go pd pe qn gr pg ph qo pj pk pl qp pn po pp qq pr ps pt bj\" data-selectable-paragraph=\"\"><strong class=\"al\">Data preparation<\/strong><\/h1>\n<p id=\"0d6b\" class=\"pw-post-body-paragraph mz na fo be b gm pu nc nd gp pv nf ng nh pw nj nk nl px nn no np py nr ns nt fh bj\" data-selectable-paragraph=\"\">The dataset is available on HuggingFace. You\u2019ll need to download it, convert it to a pandas DataFrame, and finally, remove any empty strings:<\/p>\n<pre class=\"mi mj mk ml mm qd qe qf qg ax qh bj\"><span id=\"96e0\" class=\"qi oz fo qe b ia qj qk l iq ql\" data-selectable-paragraph=\"\">from datasets import load_dataset\nimport pandas as pd\nimport numpy as np<\/span><span id=\"0ee3\" class=\"qi oz fo qe b ia qr qk l iq ql\" data-selectable-paragraph=\"\">dataset = load_dataset(\u201csuccinctly\/midjourney-prompts\u201d)\ndf = dataset[\u2018test\u2019].to_pandas()\ndf = df[df[\u2018text\u2019].str.strip().astype(bool)]<\/span><\/pre>\n<h1 id=\"ad7c\" class=\"oy oz fo be pa pb qm go pd pe qn gr pg ph qo pj pk pl qp pn po pp qq pr ps pt bj\" data-selectable-paragraph=\"\"><strong class=\"al\">Create and visualize word embeddings<\/strong><\/h1>\n<p id=\"c4a2\" class=\"pw-post-body-paragraph mz na fo be b gm pu nc nd gp pv nf ng nh pw nj nk nl px nn no np py nr ns nt fh bj\" data-selectable-paragraph=\"\">Word embeddings are a way to represent text where words that have the same meaning have a similar representation. This representation helps machines understand languages and can be applied to natural language processing pipelines. For our use case, we\u2019ll use word embeddings to explore similar prompts and cluster prompts into topics in an unsupervised manner.<\/p>\n<p id=\"8f0d\" class=\"pw-post-body-paragraph mz na fo be b gm nb nc nd gp ne nf ng nh ni nj nk nl nm nn no np nq nr ns nt fh bj\" data-selectable-paragraph=\"\">To get started, you need to get your API key from Cohere\u2019s platform. Log in to your account and create a key in the dashboard section as shown below:<\/p>\n<figure class=\"mi mj mk ml mm mn mf mg paragraph-image\">\n<div class=\"mo mp eb mq bg mr\" tabindex=\"0\" role=\"button\">\n<figure><img loading=\"lazy\" decoding=\"async\" class=\"bg ms mt c\" role=\"presentation\" src=\"https:\/\/miro.medium.com\/v2\/resize:fit:700\/1*mxb3sNfokvSQi_P0qSoSEA.png\" alt=\"\" width=\"700\" height=\"327\"><\/figure><div class=\"mf mg qs\"><picture><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/format:webp\/1*mxb3sNfokvSQi_P0qSoSEA.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/format:webp\/1*mxb3sNfokvSQi_P0qSoSEA.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/format:webp\/1*mxb3sNfokvSQi_P0qSoSEA.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/format:webp\/1*mxb3sNfokvSQi_P0qSoSEA.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/format:webp\/1*mxb3sNfokvSQi_P0qSoSEA.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/format:webp\/1*mxb3sNfokvSQi_P0qSoSEA.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:1400\/format:webp\/1*mxb3sNfokvSQi_P0qSoSEA.png 1400w\" type=\"image\/webp\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 700px\"><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/1*mxb3sNfokvSQi_P0qSoSEA.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/1*mxb3sNfokvSQi_P0qSoSEA.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/1*mxb3sNfokvSQi_P0qSoSEA.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/1*mxb3sNfokvSQi_P0qSoSEA.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/1*mxb3sNfokvSQi_P0qSoSEA.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/1*mxb3sNfokvSQi_P0qSoSEA.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:1400\/1*mxb3sNfokvSQi_P0qSoSEA.png 1400w\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 700px\" data-testid=\"og\"><\/picture><\/div>\n<\/div>\n<figcaption class=\"mu mv mw mf mg mx my be b bf z dv\" data-selectable-paragraph=\"\">Create API key in your dashboard<\/figcaption>\n<\/figure>\n<p id=\"6038\" class=\"pw-post-body-paragraph mz na fo be b gm nb nc nd gp ne nf ng nh ni nj nk nl nm nn no np nq nr ns nt fh bj\" data-selectable-paragraph=\"\">Initialize the cohere plugin with your key and call the embed endpoint. The endpoint accepts a list of texts you want to process and returns a list of floating point numbers. Append the embeddings to the original DataFrame. You can learn more about <a class=\"af oa\" href=\"https:\/\/docs.cohere.ai\/embed-reference\/\" target=\"_blank\" rel=\"noopener ugc nofollow\">Cohere\u2019s Embed Endpoint here<\/a>.<\/p>\n<pre class=\"mi mj mk ml mm qd qe qf qg ax qh bj\"><span id=\"8496\" class=\"qi oz fo qe b ia qj qk l iq ql\" data-selectable-paragraph=\"\">import cohere\nco = cohere.Client('&lt;api_key&gt;')\ndf['text_embeds']=co.embed(model='small',\n                           texts=df['text'].tolist()).embeddings<\/span><\/pre>\n<p id=\"839a\" class=\"pw-post-body-paragraph mz na fo be b gm nb nc nd gp ne nf ng nh ni nj nk nl nm nn no np nq nr ns nt fh bj\" data-selectable-paragraph=\"\">To visualize the embeddings, you need to reduce them to two dimensions using Principal Component Analysis (<a class=\"af oa\" href=\"https:\/\/en.wikipedia.org\/wiki\/Principal_component_analysis#:~:text=Principal%20component%20analysis%20(PCA)%20is,components%20and%20ignoring%20the%20rest.\" target=\"_blank\" rel=\"noopener ugc nofollow\">PCA<\/a>). Create two functions \u2014 one for creating the principal component analysis, and the other one for plotting a scatter plot:<\/p>\n<pre>from sklearn.decomposition import PCA\nimport altair as alt\n\n# Compute the principal components\ndef get_pc(arr,n):\n  pca = PCA(n_components=n)\n  embeds_transform = pca.fit_transform(arr)\n  return embeds_transform\n\n# Generate scatter plots\ndef scatter_plot(df,xcol,ycol,color='basic',title=''):\n  chart = alt.Chart(df).mark_circle(size=500).encode(\n    x= alt.X(xcol,\n      scale=alt.Scale(zero=False),\n      axis=alt.Axis(labels=False, ticks=False, domain=False)\n    ),\n    y= alt.Y(ycol,\n      scale=alt.Scale(zero=False),\n      axis=alt.Axis(labels=False, ticks=False, domain=False)\n    ),\n    color= alt.value('#333293') if color == 'basic' else color,\n    tooltip=['text']\n  )\n  result = chart.configure(background=\"#FFF\"\n        ).properties(\n        width=800,\n        height=500,\n        title=title\n       ).configure_legend(\n  orient='bottom', titleFontSize=18,labelFontSize=18)\n  return result<\/pre>\n<p id=\"0261\" class=\"pw-post-body-paragraph mz na fo be b gm nb nc nd gp ne nf ng nh ni nj nk nl nm nn no np nq nr ns nt fh bj\" data-selectable-paragraph=\"\">With the two functions created, calculate the principal components using the word embeddings, then plot them:<\/p>\n<pre class=\"mi mj mk ml mm qd qe qf qg ax qh bj\"><span id=\"3107\" class=\"qi oz fo qe b ia qj qk l iq ql\" data-selectable-paragraph=\"\">embeds = np.array(df[\u2018text_embeds\u2019].tolist())\nembeds_pc = get_pc(embeds,2)<\/span><span id=\"69bb\" class=\"qi oz fo qe b ia qr qk l iq ql\" data-selectable-paragraph=\"\"># Append the principal components to dataframe\ndf = pd.concat([df, pd.DataFrame(embeds_pc)], axis=1)<\/span><span id=\"3eed\" class=\"qi oz fo qe b ia qr qk l iq ql\" data-selectable-paragraph=\"\"># Plot the 2D embeddings on a chart\ndf.columns = df.columns.astype(str)\nsample = 500<\/span><\/pre>\n<p id=\"a52b\" class=\"pw-post-body-paragraph mz na fo be b gm nb nc nd gp ne nf ng nh ni nj nk nl nm nn no np nq nr ns nt fh bj\" data-selectable-paragraph=\"\">The scatter plot generated displays all the text prompts analyzed. Prompts that have similar meanings are closer to each other.<\/p>\n<figure class=\"mi mj mk ml mm mn mf mg paragraph-image\">\n<div class=\"mo mp eb mq bg mr\" tabindex=\"0\" role=\"button\">\n<figure><img loading=\"lazy\" decoding=\"async\" class=\"bg ms mt c\" role=\"presentation\" src=\"https:\/\/miro.medium.com\/v2\/resize:fit:700\/1*9GN8fG0LTDqdhbTCNuUJZQ.png\" alt=\"\" width=\"700\" height=\"464\"><\/figure><div class=\"mf mg qw\"><picture><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/format:webp\/1*9GN8fG0LTDqdhbTCNuUJZQ.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/format:webp\/1*9GN8fG0LTDqdhbTCNuUJZQ.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/format:webp\/1*9GN8fG0LTDqdhbTCNuUJZQ.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/format:webp\/1*9GN8fG0LTDqdhbTCNuUJZQ.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/format:webp\/1*9GN8fG0LTDqdhbTCNuUJZQ.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/format:webp\/1*9GN8fG0LTDqdhbTCNuUJZQ.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:1400\/format:webp\/1*9GN8fG0LTDqdhbTCNuUJZQ.png 1400w\" type=\"image\/webp\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 700px\"><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/1*9GN8fG0LTDqdhbTCNuUJZQ.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/1*9GN8fG0LTDqdhbTCNuUJZQ.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/1*9GN8fG0LTDqdhbTCNuUJZQ.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/1*9GN8fG0LTDqdhbTCNuUJZQ.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/1*9GN8fG0LTDqdhbTCNuUJZQ.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/1*9GN8fG0LTDqdhbTCNuUJZQ.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:1400\/1*9GN8fG0LTDqdhbTCNuUJZQ.png 1400w\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 700px\" data-testid=\"og\"><\/picture><\/div>\n<\/div>\n<\/figure>\n<h1 id=\"ce0b\" class=\"oy oz fo be pa pb qm go pd pe qn gr pg ph qo pj pk pl qp pn po pp qq pr ps pt bj\" data-selectable-paragraph=\"\"><strong class=\"al\">Semantic search for prompts<\/strong><\/h1>\n<p id=\"b078\" class=\"pw-post-body-paragraph mz na fo be b gm pu nc nd gp pv nf ng nh pw nj nk nl px nn no np py nr ns nt fh bj\" data-selectable-paragraph=\"\">This is a technique that will allow you to find prompts that have a similar meaning to your search query. It goes beyond returning results that match keywords in the search query, by utilizing the word embeddings created above and calculating similarity based on physical distance. First, create a function that calculates a similarity score between two given word embeddings:<\/p>\n<pre>from sklearn.metrics.pairwise import cosine_similarity\n\ndef get_similarity(target,candidates):\n  # Turn list into array\n  candidates = np.array(candidates)\n  target = np.expand_dims(np.array(target),axis=0)\n\n  # Calculate cosine similarity\n  sim = cosine_similarity(target,candidates)\n  sim = np.squeeze(sim).tolist()\n  sort_index = np.argsort(sim)[::-1]\n  sort_score = [sim[i] for i in sort_index]\n  similarity_scores = zip(sort_index,sort_score)\n\n  # Return similarity scores\n  return similarity_scores<\/pre>\n<p id=\"254c\" class=\"pw-post-body-paragraph mz na fo be b gm nb nc nd gp ne nf ng nh ni nj nk nl nm nn no np nq nr ns nt fh bj\" data-selectable-paragraph=\"\">Next, create word embeddings for your search query and compute the similarity scores between them and the embeddings of our prompts:<\/p>\n<pre>query = \"cartoon animals high definition\"\n# embeddings of the search query\nquery_embeds = co.embed( model='small', texts=[query]).embeddings[0]\n# similarity between the query and existing prompts\nsimilarity = get_similarity(search_query_embeds,embeds[:sample])\n\nprint('Similar prompts:')\nfor idx,sim in similarity:\n  if sim &gt;= 0.30:\n    df.at[idx,'similar'] = 'yes'\n  else:\n    df.at[idx,'similar'] = 'no'\n  print(f'Similarity: {sim:.2f};',df.iloc[idx]['text'])<\/pre>\n<p id=\"f6f7\" class=\"pw-post-body-paragraph mz na fo be b gm nb nc nd gp ne nf ng nh ni nj nk nl nm nn no np nq nr ns nt fh bj\" data-selectable-paragraph=\"\">You can display a scatter plot to visualize the similarity of prompts. You\u2019ll notice that similar results generally appear closer to each other.<\/p>\n<figure class=\"mi mj mk ml mm mn mf mg paragraph-image\">\n<div class=\"mo mp eb mq bg mr\" tabindex=\"0\" role=\"button\">\n<figure><img loading=\"lazy\" decoding=\"async\" class=\"bg ms mt c\" role=\"presentation\" src=\"https:\/\/miro.medium.com\/v2\/resize:fit:700\/1*oVN4zWGNUOCdGpuawy9x-g.png\" alt=\"\" width=\"700\" height=\"514\"><\/figure><div class=\"mf mg qw\"><picture><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/format:webp\/1*oVN4zWGNUOCdGpuawy9x-g.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/format:webp\/1*oVN4zWGNUOCdGpuawy9x-g.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/format:webp\/1*oVN4zWGNUOCdGpuawy9x-g.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/format:webp\/1*oVN4zWGNUOCdGpuawy9x-g.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/format:webp\/1*oVN4zWGNUOCdGpuawy9x-g.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/format:webp\/1*oVN4zWGNUOCdGpuawy9x-g.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:1400\/format:webp\/1*oVN4zWGNUOCdGpuawy9x-g.png 1400w\" type=\"image\/webp\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 700px\"><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/1*oVN4zWGNUOCdGpuawy9x-g.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/1*oVN4zWGNUOCdGpuawy9x-g.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/1*oVN4zWGNUOCdGpuawy9x-g.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/1*oVN4zWGNUOCdGpuawy9x-g.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/1*oVN4zWGNUOCdGpuawy9x-g.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/1*oVN4zWGNUOCdGpuawy9x-g.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:1400\/1*oVN4zWGNUOCdGpuawy9x-g.png 1400w\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 700px\" data-testid=\"og\"><\/picture><\/div>\n<\/div>\n<\/figure>\n<h1 id=\"85eb\" class=\"oy oz fo be pa pb qm go pd pe qn gr pg ph qo pj pk pl qp pn po pp qq pr ps pt bj\" data-selectable-paragraph=\"\"><strong class=\"al\">Topic clustering<\/strong><\/h1>\n<p id=\"7c93\" class=\"pw-post-body-paragraph mz na fo be b gm pu nc nd gp pv nf ng nh pw nj nk nl px nn no np py nr ns nt fh bj\" data-selectable-paragraph=\"\">In this final section, we will explore the various topics in the prompts dataset. We will use the KMeans algorithm to create ten clusters of prompts. This algorithm is unsupervised, meaning the clusters are not labeled. However, you can plot word clouds to identify top keywords in each cluster and manually label these afterwards if you choose.<\/p>\n<p id=\"de54\" class=\"pw-post-body-paragraph mz na fo be b gm nb nc nd gp ne nf ng nh ni nj nk nl nm nn no np nq nr ns nt fh bj\" data-selectable-paragraph=\"\">First, use scikit-learn library to set the number of clusters and fit the model:<\/p>\n<pre class=\"mi mj mk ml mm qd qe qf qg ax qh bj\"><span id=\"7564\" class=\"qi oz fo qe b ia qj qk l iq ql\" data-selectable-paragraph=\"\">from sklearn.cluster import KMeans<\/span><span id=\"281d\" class=\"qi oz fo qe b ia qr qk l iq ql\" data-selectable-paragraph=\"\">n_clusters=5<\/span><span id=\"b4ec\" class=\"qi oz fo qe b ia qr qk l iq ql\" data-selectable-paragraph=\"\"># Cluster the embeddings\nkmeans_model = KMeans(n_clusters=n_clusters, random_state=0)\nclasses = kmeans_model.fit_predict(embeds).tolist()\ndf[\u2018cluster\u2019] = (list(map(str,classes)))<\/span><\/pre>\n<p id=\"167f\" class=\"pw-post-body-paragraph mz na fo be b gm nb nc nd gp ne nf ng nh ni nj nk nl nm nn no np nq nr ns nt fh bj\" data-selectable-paragraph=\"\">Next, create word clouds for each cluster and plot them. Observe and note the main topic for each cluster:<\/p>\n<pre>from wordcloud import WordCloud, STOPWORDS\nimport matplotlib.pyplot as plt\nstopwords = set(STOPWORDS)\n\nfor n in range(n_clusters):\n  df_wordcloud = df.loc[df['cluster'] == str(n)]\n  text = \" \".join(i for i in df_wordcloud.text)\n  wordcloud = WordCloud(width = 800, height = 800,\n                background_color ='white',\n                stopwords = stopwords,\n                min_font_size = 10).generate(text)\n  plt.figure(figsize = (8, 8), facecolor = None)\n  plt.imshow(wordcloud)\n  plt.axis(\"off\")\n  plt.tight_layout(pad = 0)\n\n  # plt.show()<\/pre>\n<figure class=\"mi mj mk ml mm mn mf mg paragraph-image\">\n<figure><img loading=\"lazy\" decoding=\"async\" class=\"bg ms mt c\" role=\"presentation\" src=\"https:\/\/miro.medium.com\/v2\/resize:fit:600\/1*y1dX9b3FJXUUTeq7D1uRJA.gif\" alt=\"\" width=\"600\" height=\"338\"><\/figure><div class=\"mf mg qx\"><picture><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/1*y1dX9b3FJXUUTeq7D1uRJA.gif 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/1*y1dX9b3FJXUUTeq7D1uRJA.gif 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/1*y1dX9b3FJXUUTeq7D1uRJA.gif 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/1*y1dX9b3FJXUUTeq7D1uRJA.gif 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/1*y1dX9b3FJXUUTeq7D1uRJA.gif 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/1*y1dX9b3FJXUUTeq7D1uRJA.gif 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:1200\/1*y1dX9b3FJXUUTeq7D1uRJA.gif 1200w\" type=\"image\/webp\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 600px\"><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/1*y1dX9b3FJXUUTeq7D1uRJA.gif 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/1*y1dX9b3FJXUUTeq7D1uRJA.gif 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/1*y1dX9b3FJXUUTeq7D1uRJA.gif 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/1*y1dX9b3FJXUUTeq7D1uRJA.gif 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/1*y1dX9b3FJXUUTeq7D1uRJA.gif 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/1*y1dX9b3FJXUUTeq7D1uRJA.gif 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:1200\/1*y1dX9b3FJXUUTeq7D1uRJA.gif 1200w\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 600px\" data-testid=\"og\"><\/picture><\/div>\n<\/figure>\n<p id=\"3422\" class=\"pw-post-body-paragraph mz na fo be b gm nb nc nd gp ne nf ng nh ni nj nk nl nm nn no np nq nr ns nt fh bj\" data-selectable-paragraph=\"\">Finally, label the clusters and generate the scatter plot.<\/p>\n<pre class=\"mi mj mk ml mm qd qe qf qg ax qh bj\"><span id=\"225b\" class=\"qi oz fo qe b ia qj qk l iq ql\" data-selectable-paragraph=\"\"># labels the clusters after looking at keywords in each clusterdf['cluster'] = df['cluster'].replace([\"0\",'1','2','3','4'],\n                                ['optimization','datasets',\n                                 'reasoning', 'manipulation',\n                                 'NLP'])\ndf.columns = df.columns.astype(str)\nscatter_plot(df.iloc[:sample],'0','1',color='cluster',\n             title='Prompts clustered into 5 topics')<\/span><\/pre>\n<figure class=\"mi mj mk ml mm mn mf mg paragraph-image\">\n<div class=\"mo mp eb mq bg mr\" tabindex=\"0\" role=\"button\">\n<figure><img loading=\"lazy\" decoding=\"async\" class=\"bg ms mt c\" role=\"presentation\" src=\"https:\/\/miro.medium.com\/v2\/resize:fit:700\/1*Zrs9Tz0wt5e9Ax2UUl4Tjg.png\" alt=\"\" width=\"700\" height=\"464\"><\/figure><div class=\"mf mg qy\"><picture><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/format:webp\/1*Zrs9Tz0wt5e9Ax2UUl4Tjg.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/format:webp\/1*Zrs9Tz0wt5e9Ax2UUl4Tjg.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/format:webp\/1*Zrs9Tz0wt5e9Ax2UUl4Tjg.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/format:webp\/1*Zrs9Tz0wt5e9Ax2UUl4Tjg.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/format:webp\/1*Zrs9Tz0wt5e9Ax2UUl4Tjg.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/format:webp\/1*Zrs9Tz0wt5e9Ax2UUl4Tjg.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:1400\/format:webp\/1*Zrs9Tz0wt5e9Ax2UUl4Tjg.png 1400w\" type=\"image\/webp\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 700px\"><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/1*Zrs9Tz0wt5e9Ax2UUl4Tjg.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/1*Zrs9Tz0wt5e9Ax2UUl4Tjg.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/1*Zrs9Tz0wt5e9Ax2UUl4Tjg.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/1*Zrs9Tz0wt5e9Ax2UUl4Tjg.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/1*Zrs9Tz0wt5e9Ax2UUl4Tjg.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/1*Zrs9Tz0wt5e9Ax2UUl4Tjg.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:1400\/1*Zrs9Tz0wt5e9Ax2UUl4Tjg.png 1400w\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 700px\" data-testid=\"og\"><\/picture><\/div>\n<\/div>\n<\/figure>\n<h1 id=\"2576\" class=\"oy oz fo be pa pb qm go pd pe qn gr pg ph qo pj pk pl qp pn po pp qq pr ps pt bj\" data-selectable-paragraph=\"\"><strong class=\"al\">Conclusion<\/strong><\/h1>\n<p id=\"d83d\" class=\"pw-post-body-paragraph mz na fo be b gm pu nc nd gp pv nf ng nh pw nj nk nl px nn no np py nr ns nt fh bj\" data-selectable-paragraph=\"\">Text-to-image generators present many opportunities for people in the creative fields. We have learned some of the top AI solutions currently in the market and how they work. Additionally, by analyzing a large dataset of prompts, we were able to understand how to create our own prompts and calculate the similarity of prompts. Through semantic search, we can find prompt ideas that are close to what we are looking to achieve. We can extend this analysis by adding sentiment analysis and add mood to the mix. Don\u2019t miss the next part of this tutorial, where we are going to train a prompt generator that creates prompts for us!<\/p>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Art by DALL-E 2 Text-to-image generators are currently a red hot topic in the field of AI art. With them, a user can provide text describing the artwork they\u2019d like to output, and the machine generates different variations of this image (sometimes in less than a minute!). Deep learning powers this technology, which helps anyone [&hellip;]<\/p>\n","protected":false},"author":65,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"customer_name":"","customer_description":"","customer_industry":"","customer_technologies":"","customer_logo":"","footnotes":""},"categories":[6],"tags":[],"coauthors":[165],"class_list":["post-7054","post","type-post","status-publish","format-standard","hentry","category-machine-learning"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v25.9 (Yoast SEO v25.9) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>NLP for Text-to-Image Generators: Prompt Analysis [Part 1] - Comet<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.comet.com\/site\/blog\/nlp-for-text-to-image-generators-prompt-analysis-part-1\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"NLP for Text-to-Image Generators: Prompt Analysis [Part 1]\" \/>\n<meta property=\"og:description\" content=\"Art by DALL-E 2 Text-to-image generators are currently a red hot topic in the field of AI art. With them, a user can provide text describing the artwork they\u2019d like to output, and the machine generates different variations of this image (sometimes in less than a minute!). Deep learning powers this technology, which helps anyone [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.comet.com\/site\/blog\/nlp-for-text-to-image-generators-prompt-analysis-part-1\/\" \/>\n<meta property=\"og:site_name\" content=\"Comet\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/cometdotml\" \/>\n<meta property=\"article:published_time\" content=\"2023-08-08T19:46:11+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-04-24T17:14:57+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/miro.medium.com\/v2\/resize:fit:700\/1*uY2VNRs34bfnz0DfSOeSfw.jpeg\" \/>\n<meta name=\"author\" content=\"Klurdy Studios\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@Cometml\" \/>\n<meta name=\"twitter:site\" content=\"@Cometml\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Klurdy Studios\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"NLP for Text-to-Image Generators: Prompt Analysis [Part 1] - Comet","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.comet.com\/site\/blog\/nlp-for-text-to-image-generators-prompt-analysis-part-1\/","og_locale":"en_US","og_type":"article","og_title":"NLP for Text-to-Image Generators: Prompt Analysis [Part 1]","og_description":"Art by DALL-E 2 Text-to-image generators are currently a red hot topic in the field of AI art. With them, a user can provide text describing the artwork they\u2019d like to output, and the machine generates different variations of this image (sometimes in less than a minute!). Deep learning powers this technology, which helps anyone [&hellip;]","og_url":"https:\/\/www.comet.com\/site\/blog\/nlp-for-text-to-image-generators-prompt-analysis-part-1\/","og_site_name":"Comet","article_publisher":"https:\/\/www.facebook.com\/cometdotml","article_published_time":"2023-08-08T19:46:11+00:00","article_modified_time":"2025-04-24T17:14:57+00:00","og_image":[{"url":"https:\/\/miro.medium.com\/v2\/resize:fit:700\/1*uY2VNRs34bfnz0DfSOeSfw.jpeg","type":"","width":"","height":""}],"author":"Klurdy Studios","twitter_card":"summary_large_image","twitter_creator":"@Cometml","twitter_site":"@Cometml","twitter_misc":{"Written by":"Klurdy Studios","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.comet.com\/site\/blog\/nlp-for-text-to-image-generators-prompt-analysis-part-1\/#article","isPartOf":{"@id":"https:\/\/www.comet.com\/site\/blog\/nlp-for-text-to-image-generators-prompt-analysis-part-1\/"},"author":{"name":"Klurdy Studios","@id":"https:\/\/www.comet.com\/site\/#\/schema\/person\/069e186ad4a5b6d6950292821ea0f37b"},"headline":"NLP for Text-to-Image Generators: Prompt Analysis [Part 1]","datePublished":"2023-08-08T19:46:11+00:00","dateModified":"2025-04-24T17:14:57+00:00","mainEntityOfPage":{"@id":"https:\/\/www.comet.com\/site\/blog\/nlp-for-text-to-image-generators-prompt-analysis-part-1\/"},"wordCount":968,"publisher":{"@id":"https:\/\/www.comet.com\/site\/#organization"},"image":{"@id":"https:\/\/www.comet.com\/site\/blog\/nlp-for-text-to-image-generators-prompt-analysis-part-1\/#primaryimage"},"thumbnailUrl":"https:\/\/miro.medium.com\/v2\/resize:fit:700\/1*uY2VNRs34bfnz0DfSOeSfw.jpeg","articleSection":["Machine Learning"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.comet.com\/site\/blog\/nlp-for-text-to-image-generators-prompt-analysis-part-1\/","url":"https:\/\/www.comet.com\/site\/blog\/nlp-for-text-to-image-generators-prompt-analysis-part-1\/","name":"NLP for Text-to-Image Generators: Prompt Analysis [Part 1] - Comet","isPartOf":{"@id":"https:\/\/www.comet.com\/site\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.comet.com\/site\/blog\/nlp-for-text-to-image-generators-prompt-analysis-part-1\/#primaryimage"},"image":{"@id":"https:\/\/www.comet.com\/site\/blog\/nlp-for-text-to-image-generators-prompt-analysis-part-1\/#primaryimage"},"thumbnailUrl":"https:\/\/miro.medium.com\/v2\/resize:fit:700\/1*uY2VNRs34bfnz0DfSOeSfw.jpeg","datePublished":"2023-08-08T19:46:11+00:00","dateModified":"2025-04-24T17:14:57+00:00","breadcrumb":{"@id":"https:\/\/www.comet.com\/site\/blog\/nlp-for-text-to-image-generators-prompt-analysis-part-1\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.comet.com\/site\/blog\/nlp-for-text-to-image-generators-prompt-analysis-part-1\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.comet.com\/site\/blog\/nlp-for-text-to-image-generators-prompt-analysis-part-1\/#primaryimage","url":"https:\/\/miro.medium.com\/v2\/resize:fit:700\/1*uY2VNRs34bfnz0DfSOeSfw.jpeg","contentUrl":"https:\/\/miro.medium.com\/v2\/resize:fit:700\/1*uY2VNRs34bfnz0DfSOeSfw.jpeg"},{"@type":"BreadcrumbList","@id":"https:\/\/www.comet.com\/site\/blog\/nlp-for-text-to-image-generators-prompt-analysis-part-1\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.comet.com\/site\/"},{"@type":"ListItem","position":2,"name":"NLP for Text-to-Image Generators: Prompt Analysis [Part 1]"}]},{"@type":"WebSite","@id":"https:\/\/www.comet.com\/site\/#website","url":"https:\/\/www.comet.com\/site\/","name":"Comet","description":"Build Better Models Faster","publisher":{"@id":"https:\/\/www.comet.com\/site\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.comet.com\/site\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.comet.com\/site\/#organization","name":"Comet ML, Inc.","alternateName":"Comet","url":"https:\/\/www.comet.com\/site\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.comet.com\/site\/#\/schema\/logo\/image\/","url":"https:\/\/www.comet.com\/site\/wp-content\/uploads\/2025\/01\/logo_comet_square.png","contentUrl":"https:\/\/www.comet.com\/site\/wp-content\/uploads\/2025\/01\/logo_comet_square.png","width":310,"height":310,"caption":"Comet ML, Inc."},"image":{"@id":"https:\/\/www.comet.com\/site\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/cometdotml","https:\/\/x.com\/Cometml","https:\/\/www.youtube.com\/channel\/UCmN63HKvfXSCS-UwVwmK8Hw"]},{"@type":"Person","@id":"https:\/\/www.comet.com\/site\/#\/schema\/person\/069e186ad4a5b6d6950292821ea0f37b","name":"Klurdy Studios","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.comet.com\/site\/#\/schema\/person\/image\/b1a3bf3caaa793aaad2da005b3ba38ba","url":"https:\/\/www.comet.com\/site\/wp-content\/uploads\/2023\/08\/1635710213869-96x96.jpg","contentUrl":"https:\/\/www.comet.com\/site\/wp-content\/uploads\/2023\/08\/1635710213869-96x96.jpg","caption":"Klurdy Studios"},"url":"https:\/\/www.comet.com\/site\/blog\/author\/brianklurdy-com\/"}]}},"_links":{"self":[{"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/posts\/7054","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/users\/65"}],"replies":[{"embeddable":true,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/comments?post=7054"}],"version-history":[{"count":1,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/posts\/7054\/revisions"}],"predecessor-version":[{"id":15589,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/posts\/7054\/revisions\/15589"}],"wp:attachment":[{"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/media?parent=7054"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/categories?post=7054"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/tags?post=7054"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/coauthors?post=7054"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}