[Trying out AI persona marketing with NVIDIA DGX Spark]
Episode 1: Overview of the Demo
Episode 2: Selection of Survey Subjects
Episode 3: Question Generation
Episode 4: Generating and Collecting Responses
Episode 5: Visualizing the Survey Results
Episode 6 Summary
Contents of this story
This presentation explains the process of generating survey questions and answer choices using a Large-Scale Language Model (LLM). In typical marketing activities, marketing personnel would devise survey questions and answer choices themselves with a clear intention, but in this demo, we explored the potential of AI in this area as well. The LLM used was openai/gpt-oss-120b.
Setting up the LLM API endpoint and configuring the client
In this demo, all processing, including LLM, is executed locally on DGX Spark. However, just as when accessing LLM in the cloud, we access LLM via an HTTP API endpoint. Therefore, we set up an API endpoint at http://localhost. We used vLLM as the inference server. For information on installing and running vLLM, please refer to the following article.
DGX Spark Playbook : vLLM for Inference
Even when running LLM locally, using the HTTP API as an interface allows for easy switching to another LLM served on the cloud or another server simply by changing the address and model name.
The client-side settings are configured as follows. There are several ways to access the LLM API endpoint, but this time we used the OpenAI Python API.
import json
from openai import OpenAI
from survey import Survey
# LLM APIエンドポイントの設定 MODEL = "openai/gpt-oss-120b" BASE_URL = "http://localhost:8000/v1"
# OpenAIクライアントの初期化 client = OpenAI( base_url=BASE_URL, api_key="None" )
Question generation
To instruct the LLM to generate questions, we prepare system prompts and user prompts. The system prompt assigns a role to the LLM, and the user prompt provides specific instructions.
# システムプロンプトの定義 system_prompt = """ あなたは一般消費者向け商品のマーケティング専門家です。 主に一般消費者からの意見をヒアリングし、分析する業務を行っています。 あなたの顧客である企業から、分析したい内容が与えられますので、よく内容を理解した上で、最適な提案を提出してください。 """
# ユーザープロンプトの定義 user_prompt = """ 20代向けグミ菓子を企画しています。 季節商品ではなく、通年販売を予定しています。 以下の項目を決めたいので、一般消費者からヒアリングを行います。 - フレーバー - パッケージのデザイン - CMに起用するタレント 最適な調査質問を5問提案してください。 各質問に対して、4個の選択肢も作成してください。 直接的な質問は避け、消費者の潜在意識を見極めるものにしてください。 質問文と選択肢には、考察や補足情報を含めず、それらは理由として別途記載してください。 """
As shown below, we've utilized the Structured model outputs feature to receive the generated questions and answer choices as structured data. This simplifies subsequent processing.
# LLMによる質問票の生成 response = client.responses.parse( model=MODEL, input=[ {"role": "system", "content": system_prompt}, {"role": "user", "content": user_prompt}, ], text_format=Survey, temperature=0.2, top_p=0.7, ) survey = response.output_parsed
The generated questions and answer choices are output as objects of the Survey class. The Survey class is defined as follows:
from pydantic import BaseModel class Choice(BaseModel): """質問の選択肢""" text: str class Question(BaseModel): """消費者の潜在意識を見極めるための質問""" question_text: str # 質問文 choices: list[Choice] # 質問に対する選択肢のリスト reason: str # 質問の意図や背景に関する説明 class Survey(BaseModel): """グミ菓子新製品に関する消費者調査票""" questions: list[Question]
The generated questions and answer choices are received in JSON format as follows:
# 結果をJSON形式で取得 json_data =json.loads(survey.model_dump_json(ensure_ascii=False)) json_data
The generated questions and answer choices were as follows:
{'questions': [{'question_text': '朝の目覚めに、あなたが思い浮かべる“さわやかさ”はどのシーンですか?', 'choices': [{'text': '海辺の朝日が水平線から顔を出す瞬間'}, {'text': '高原の風が葉を揺らす音と共に吹く瞬間'}, {'text': '都会のカフェで、窓の外に映るネオンが光る瞬間'}, {'text': '秋の森の中で、落ち葉がカサカサと音を立てる瞬間'}], 'reason': 'フレーバーのイメージ(トロピカル、ミント系、シトラス系、秋味)を直接聞かずに、自然・都市・季節の連想から好みを測る。'}, {'question_text': 'コンビニで新しいスナックを選ぶとき、どのパッケージが最初に手に取られそうですか?', 'choices': [{'text': '淡いパステルカラーでシンプルなロゴが配置されたデザイン'}, {'text': '鮮やかなネオンカラーとダイナミックなパターンが走るデザイン'}, {'text': 'レトロなイラストと温かみのあるトーンでまとめられたデザイン'}, {'text': '黒を基調にメタリックなアクセントが入ったモダンなデザイン'}], 'reason': '色彩・スタイルの好みを直接聞かず、視覚的な第一印象からパッケージデザインの嗜好を把握する。'}, {'question_text': '友達と週末に新しいお菓子をシェアするとしたら、どんなシチュエーションが一番楽しいですか?', 'choices': [{'text': '自然の中でハイキングやピクニックをしながら'}, {'text': '屋外フェスやライブで音楽に合わせて'}, {'text': 'カフェでゆっくりおしゃべりしながら'}, {'text': '自宅でゲームや映画鑑賞をしながら'}], 'reason': 'シーン別のライフスタイルを通じて、フレーバーのイメージ(フルーツ系、エナジー系、リラックス系、甘さ重視)とパッケージの使用シーンを間接的に探る。'}, {'question_text': 'テレビやSNSで有名人が商品を紹介しているとき、あなたが「信頼できる」と感じるのはどんな雰囲気ですか?', 'choices': [{'text': '自然体で笑いを交えたユーモラスな雰囲気'}, {'text': '自分の経験や感情を率直に語る誠実さ'}, {'text': '専門的な知識やスキルを活かした説得力'}, {'text': '最新トレンドを先取りするクールさ'}], 'reason': 'タレント選定の指標となる「信頼感」の要素(ユーモア、誠実さ、専門性、トレンド感)を直接的に尋ねず、感情的な評価で測定する。'}, {'question_text': '新しいスナックを食べるとき、どのような音楽が流れていると最もリラックスできますか?', 'choices': [{'text': '軽快なポップス'}, {'text': 'リズミカルなヒップホップ'}, {'text': '落ち着いたインディー・アコースティック'}, {'text': 'エレガントなジャズやクラシック'}], 'reason': 'CMに起用するタレントの音楽的イメージ(明るさ、エネルギー、落ち着き、上品さ)を音楽好みから間接的に把握し、タレントのパーソナリティ選定に活かす。'}]}
Finally, the generated question and answer data is saved to a file.
# 結果をファイルに保存 with open("survey.json", "w", encoding="utf-8") as f: json.dump(json_data, f, indent=4, ensure_ascii=False)
Summary of this episode
We've shown you how to generate survey questions and answer choices using LLM. By using LLM's Structured Output function, you can easily obtain structured data from LLM, making post-processing such as formatting the obtained data much easier.
In the next episode, we will explain how to instruct LLMs to answer questionnaires while taking persona data into consideration.