This is a viewer only at the moment see the article on how this works.
To update the preview hit Ctrl-Alt-R (or ⌘-Alt-R on Mac) or Enter to refresh. The Save icon lets you save the markdown file to disk
This is a preview from the server running through my markdig pipeline
Wednesday, 24 December 2025
Sisään Osa 1 käsittelimme filosofiaa: läpinäkyvää segmentointia ilman PII:tä. 2 osa kattaa istuntoprofiilit, signaalit ja segmenttimäärittelyt.
Mutta ensin: Miten voit vahvistaa mitään tästä koskematta koskaan todellisiin asiakastietoihin?
Tähän sarjaan luon täydellisen synteettisen verkkokauppatietokannan paikallisesti:
Tämä on yksi niistä, jotka tuntuvat huijaavilta työnvirroilta: saat realistisia syötteitä, voit uudistaa niitä milloin tahansa, etkä koskaan ota PII:tä käyttöön dev-ympäristöösi.
Jos rakennat segmentointia / personointia, tarvitset dataa, joka:
Todellinen data on päinvastoin: herkkää, sotkuista, vaikeasti liikuteltavaa ja täynnä historiallista puolueellisuutta.
Synteettiset tiedot antavat kolme supervaltaa:
flowchart LR
Taxonomy[gadget-taxonomy.json] --> Gen[SampleData generator]
Gen --> Products[products.json]
Gen --> Profiles[profiles.json]
Gen --> Images[images/*]
Products --> Import[Import into Postgres]
Profiles --> Import
style Taxonomy stroke:#1971c2,stroke-width:3px
style Gen stroke:#1971c2,stroke-width:3px
style Import stroke:#2f9e44,stroke-width:3px
Generaattori elää Mostlylucid.SegmentCommerce.SampleData.
Se ei tarkoituksellisesti ole kehys; se on pragmaattinen CLI, joka puhuu
Konfiguraatio on kytketty päälle, jotta voit ajaa sitä ympäristömuuttujien kautta:
// Mostlylucid.SegmentCommerce.SampleData/Program.cs
var configuration = new ConfigurationBuilder()
.SetBasePath(AppContext.BaseDirectory)
.AddJsonFile("appsettings.json", optional: true)
.AddEnvironmentVariables("SAMPLEDATA_")
.Build();
Voit tyypillisesti hoitaa kolme paikallista palvelua generaattorin rinnalla:
flowchart LR
CLI[SampleData CLI] --> Ollama["Ollama
http://localhost:11434"]
CLI --> Comfy["ComfyUI
http://localhost:8188"]
CLI -. optional .-> DB[(Postgres)]
style CLI stroke:#1971c2,stroke-width:3px
style Ollama stroke:#1971c2,stroke-width:3px
style Comfy stroke:#2f9e44,stroke-width:3px
style DB stroke:#fab005,stroke-width:3px
Suorita generaattori repojuuresta:
dotnet run --project Mostlylucid.SegmentCommerce.SampleData -- status
Luo sitten tietoaineisto:
# v1 generator: taxonomy + optional Ollama + optional ComfyUI
# Writes ./Output/products.json, ./Output/profiles.json, ./Output/images/...
dotnet run --project Mostlylucid.SegmentCommerce.SampleData -- generate --count 20
Hyödyllisiä kytkimiä:
# No LLM calls, taxonomy only
dotnet run --project Mostlylucid.SegmentCommerce.SampleData -- generate --no-ollama
# No ComfyUI images
dotnet run --project Mostlylucid.SegmentCommerce.SampleData -- generate --no-images
# Write into Postgres (uses configured connection string)
dotnet run --project Mostlylucid.SegmentCommerce.SampleData -- generate --db
Huomautus: Jos ComfyUI ei ole saatavilla, v1-generaattori putoaa takaisin paikanninkuviin (se käyttää picsum.photos, Niin, että polku ei ole täysin offline. Jos haluat tiukasti paikallista, juokse --no-images.
On olemassa myös uudempi generaattorikomento (gen), joka rakentaa täydellisemmän kauppapaikan muotoisen aineiston:
# v2 generator
# Writes dataset.json plus sellers/products/customers/orders split files
dotnet run --project Mostlylucid.SegmentCommerce.SampleData -- gen --sellers 50 --products 20 --customers 1000
Se masinoi monivaiheiseksi putkistoksi:
flowchart LR
A[Sellers] --> B[Products]
B --> C[Customers]
C --> D[Orders]
D --> E[Embeddings]
B -. optional .-> I[ComfyUI images]
style A stroke:#1971c2,stroke-width:3px
style B stroke:#1971c2,stroke-width:3px
style C stroke:#1971c2,stroke-width:3px
style D stroke:#1971c2,stroke-width:3px
style E stroke:#2f9e44,stroke-width:3px
style I stroke:#2f9e44,stroke-width:3px
Ja voit nähdä ne vaiheet suoraan koodilla:
// Mostlylucid.SegmentCommerce.SampleData/Services/DataGenerator.cs
// 1. Generate Sellers
// 2. Generate Products for each seller
// 3. Generate Customers
// 4. Generate Orders (with fake checkout data via Bogus)
// 5. Generate embeddings for all entities
V2-generaattori voi laskea upotukset ONNX-mallilla (oletus: all-MiniLM-L6-v2Se lataa mallin ja vokabin lähtökansioosi ensimmäisellä kerralla, kun suoritat sen.
Tämä tarkoittaa:
--no-embeddings// Mostlylucid.SegmentCommerce.SampleData/Services/EmbeddingService.cs
private const string ModelUrl = "https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2/resolve/main/onnx/model.onnx";
private const string VocabUrl = "https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2/resolve/main/vocab.txt";
// Download model if not exists
if (!File.Exists(_config.ModelPath))
{
await DownloadFileAsync(ModelUrl, _config.ModelPath, ct);
}
Tuotesukupolvi on tarkoituksellisesti tiukka: LLM:n on palautettava vain JSON, jossa on upotettu JSON-skeemaesimerkki.
// Mostlylucid.SegmentCommerce.SampleData/Services/OllamaProductGenerator.cs
return $"""
You are a product catalog generator for an e-commerce store. Generate {count} unique, realistic product listings for the \"{category.DisplayName}\" category.
Category description: {category.Description}
Example products in this category: {category.ExampleProducts}
Price range: £{category.PriceRange.Min:F2} - £{category.PriceRange.Max:F2}
For each product, provide:
1. A compelling product name (realistic brand-style naming)
2. A detailed description (2-3 sentences, highlighting key features and benefits)
3. A realistic price within the range
4. Optional original price if on sale (20-40% higher than current price)
5. 3-5 relevant tags
6. Whether it's trending (about 20% should be trending)
7. Whether it's featured (about 15% should be featured)
8. An image prompt for AI image generation (detailed, product photography style)
9. 2-3 colour variants for the product
IMPORTANT: Respond with ONLY valid JSON, no markdown formatting, no code blocks, no explanations.
Generate {count} diverse products now:
""";
Tällä on merkitystä, koska loppupään järjestelmät (kuvantuotanto + tuonti + upotukset) haluavat strukturoitua dataa. LLM tuottaa panostus putkeenEn kirjoita proosaa.
LLM:t eivät ole kääntäjiä. Vaikka JOSON on vainoharhainen, tarvitset silti puolustavaa ryhdistäytymistä ja sulavaa varaiskua.
V2-generaattori tekee sen pienen auttajan kautta (LlmService), joka poimii ensimmäisen {...} estää ja poistaa sen:
// Mostlylucid.SegmentCommerce.SampleData/Services/LlmService.cs
var jsonStart = response.IndexOf('{');
var jsonEnd = response.LastIndexOf('}');
if (jsonStart >= 0 && jsonEnd > jsonStart)
{
var jsonStr = response.Substring(jsonStart, jsonEnd - jsonStart + 1);
return JsonSerializer.Deserialize<T>(jsonStr, new JsonSerializerOptions
{
PropertyNameCaseInsensitive = true
});
}
Ja kokonaissukupolven putkistossa nimenomaisesti tarkistetaan käytettävyyttä ja heikennyksiä deterministisiin malleihin, jos se on tarpeen:
flowchart LR
A[EnableLlm=true?] -->|no| F[Fallback templates]
A -->|yes| B[GET /api/tags]
B -->|model present| C[LLM JSON prompts]
B -->|not available| F
style A stroke:#1971c2,stroke-width:3px
style C stroke:#2f9e44,stroke-width:3px
style F stroke:#fab005,stroke-width:3px
Asiakaskehotus on lyhyt ja jäsennelty, joten se voi syntyä nopeasti pienellä paikallisella mallilla:
// Mostlylucid.SegmentCommerce.SampleData/Services/DataGenerator.cs
var prompt = $$"""
Generate a shopper persona interested in: {{string.Join(", ", categoryNames)}}.
Return JSON only:
{
"persona": "Brief persona description (e.g. 'Tech enthusiast who values quality')",
"name": "Realistic first name",
"bio": "One sentence about their shopping habits",
"age": 25,
"shopping_style": "budget|value|premium|luxury",
"preferred_categories": ["category1", "category2"]
}
""";
ComfyUI on mahtava, koska se antaa sinulle ohjattavan putken (työnkulkua) eikä yhden mustan laatikon kuvan päätepisteen.
Generaattori:
ComfyUI/workflows/product_image.json)CLIPTextEncode/prompt/history/{promptId}/view?...sequenceDiagram
participant Gen as SampleData
participant Comfy as ComfyUI
Gen->>Comfy: POST /prompt (workflow + prompt)
Comfy-->>Gen: prompt_id
loop poll
Gen->>Comfy: GET /history/{prompt_id}
Comfy-->>Gen: outputs / images
end
Gen->>Comfy: GET /view?filename=...&type=output
Comfy-->>Gen: PNG bytes
ComfyUI-mallisto yhdistetään myös työnkulkuun ajon aikana (jotta voit vaihtaa tarkastuspisteitä muokkaamatta JSON-järjestelmää):
// Mostlylucid.SegmentCommerce.SampleData/Services/ComfyUIImageGenerator.cs
TryPatchCheckpoint(workflow, _config.ComfyUICheckpointName ?? "sd_xl_base_1.0.safetensors");
TryPatchRefiner(workflow, _config.ComfyUIRefinerName ?? "sd_xl_refiner_1.0.safetensors");
Ja työnkulku tasaantuu tarkoituksellisesti yksinkertaiseksi ja vakaaksi:
// Mostlylucid.SegmentCommerce.SampleData/Services/ComfyUIImageGenerator.cs
// Update CLIPTextEncode nodes with our prompt
if (classType == "CLIPTextEncode")
{
var inputs = nodeObj["inputs"]?.AsObject();
if (inputs != null && inputs.ContainsKey("text"))
{
var currentText = inputs["text"]?.GetValue<string>() ?? "";
if (!currentText.Contains("bad") && !currentText.Contains("ugly") && !currentText.Contains("deformed"))
{
inputs["text"] = prompt;
}
}
}
// Update image dimensions
if (classType == "EmptyLatentImage")
{
var inputs = nodeObj["inputs"]?.AsObject();
if (inputs != null)
{
inputs["width"] = _config.ImageWidth;
inputs["height"] = _config.ImageHeight;
}
}
V1-generaattori luo anonyymejä profiileja ja rikastuttaa niitä personalla (ei vieläkään PII:llä). Päädyt realistisiin testitietoihin ilman sähköposteja, osoitteita tai mitään, mitä voisit koskaan vahingossa lähettää.
V1:n profiileissa käytetään yksisuuntaista hasista, joten ei ole mitään, mistä toipua:
// Mostlylucid.SegmentCommerce.SampleData/Services/ProfileGenerator.cs
var profileKey = Hash($"fp-{Guid.NewGuid():N}");
private static string Hash(string input)
{
using var sha = SHA256.Create();
var bytes = sha.ComputeHash(Encoding.UTF8.GetBytes(input));
return Convert.ToHexString(bytes).ToLowerInvariant();
}
Se on juuri koko sarjan ajattelutapa: voit vuotaa sitä, mitä et koskaan tallentanut.
flowchart TB
Signals["Generated signals
views/cart/purchase weights"] --> Persona["Persona enrichment
Ollama JSON-only"]
Persona --> Portrait[Portrait prompt]
Portrait --> Comfy[ComfyUI]
style Signals stroke:#1971c2,stroke-width:3px
style Persona stroke:#1971c2,stroke-width:3px
style Comfy stroke:#2f9e44,stroke-width:3px
Tämä paikallinen putki on voimakas, koska se tukee mallivalidointi, ei vain demoja.
Tärkeä hienovaraisuus: luomalla molemmat teksti ja kuvat, voit validoida koko tuotekokemuksen, et vain back-end-matematiikkaa.
2 osa: Session profiileja, signaaleja ja segmenttimääritelmiä – joissa kytkemme nämä näytetiedot toimivaan segmentoitumiseen.
3 osa (tulevaisuus): Outbox-kuvio, työjono ja läpinäkyvyys-UI.
Generaattorin koodi: Mostlylucid.SegmentCommerce.SampleData/
© 2026 Scott Galloway — Unlicense — All content and source code on this site is free to use, copy, modify, and sell.