# Zero PII ग्राहक इंटेलिजेंस - भाग | 1.1: | नमूना डेटा उत्पन्न करना |( | और छवियाँ |M) | स्थानीय रूप से

<!--category-- Product, Privacy, LLM, ComfyUI, C# -->
<datetime class="hidden">2025-12-31T20:00</datetime>

में [भाग 1](/blog/zero-pii-customer-intelligence-part1) हमने दर्शन को शामिल किया है [भाग 2](/blog/zero-pii-customer-intelligence-part2) सत्र प्रोफाइलों को शामिल करता है

लेकिन पहले **कैसे आप इस में से किसी भी प्रमाणित करने के बिना कभी वास्तविक ग्राहक डेटा छूते हैं**

इस श्रृंखला के लिए मैं एक संपूर्ण संश्लेषित ई-कॉमर्स डेटासेट स्थानीय रूप से उत्पन्न करता हूँ

- उत्पाद विवरणिका (नामM SK1 वर्णन, टैग्सMSC3 कीमतें
- अनौपचारिक “प्रोफ़ाइलें” | / व्यक़्तिय |(लाभ |
- ComfyUI के माध्यम से उत्पाद छवियाँ (और प्रोफ़ाइल पोर्ट्रेट्स)
- वैकल्पिक डीबी आयात ताकि वास्तविक अनुप्रयोग इसके विरुद्ध चला जा सके

यह उन में से एक है।

## स्थानीय संश्लेषण डेटा इतनी शक्तिशाली क्यों है

यदि आप विखंडन निर्मित कर रहे हैं

- इतना विविधता है कि सहज गुस्से को तोड़ने के लिए
- साझा करने के लिए सुरक्षित हैं
- दोहराया जा सकता है (ताकि आप मॉडल परिवर्तनों की तुलना कर सकते हैं

वास्तविक आंकड़ा विपरीत है

संश्लेषण डेटा आपको तीन सुपर पावर देता है

1. **त्वरित पुनरावृत्ति**: विखंडन तर्क को बदलेंM SK1 पुनर्जीवित करें, फिर से चलाएँ
2. **कठोरता**: विचित्र लम्बे को सिमुलित करें
3. **स्पष्टता परीक्षण**: आप कर सकते हैं *प्रत्येक उत्पन्न क्षेत्र की जांच करें* और अपनी पुष्टि करें “मुझे दिखाएँ कि क्यों है

```mermaid
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
```

## औज़ारिंग (क्या वास्तव में चलाता है

जेनेरेटर में रहता है `Mostlylucid.SegmentCommerce.SampleData`.

यह अभिप्रायतः एक ढांचा नहीं है, यह एक व्यावहारिक सीएलआई है जो बातचीत करता है

- **ओलामाCity name (optional, probably does not need a translation)** संरचनात्मक JSON उत्पादन के लिए (local LLM
- **ComfyUI** उत्पाद फोटोग्राफी के लिए (स्थानीय स्थिर diffusion
- ए **वर्गीकरण JSON** जो आउटपुट को सुसंगत बनाए रखता है

कॉन्फ़िगरेशन तारित है ताकि आप इसे परिवेश चलों के माध्यम से चला सकते हैं

```csharp
// Mostlylucid.SegmentCommerce.SampleData/Program.cs
var configuration = new ConfigurationBuilder()
    .SetBasePath(AppContext.BaseDirectory)
    .AddJsonFile("appsettings.json", optional: true)
    .AddEnvironmentVariables("SAMPLEDATA_")
    .Build();
```

## त्वरित प्रारंभ

आप सामान्यतः जेनरेटर के साथ तीन स्थानीय सेवाएँ चलाएंगे

```mermaid
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
```

रेपो मूल से जेनेरेटर चलाएँ

```bash
dotnet run --project Mostlylucid.SegmentCommerce.SampleData -- status
```

फिर एक डेटासेट उत्पन्न करें

```bash
# 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
```

उपयोगी स्विच

```bash
# 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
```

ध्यान दें: यदि ComfyUI नहीं है’मौजूद नहीं है\, वी. एम. एस. सी. एल. जेनरेटर प्लेसहोल्डर छवियों में वापस आता है MSC4यह उपयोग करता है `picsum.photos`, इस तरह कि पथ नहीं है `--no-images`.

## जेनेरेटर

वहाँ भी एक नया जेनेरेटर कमांड है`gen`जो एक अधिक पूर्ण निर्माण करता है

```bash
# 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
```

यह एक बहुआयामी पाइपलाइन के रूप में orchestrated है

```mermaid
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
```

और आप इन चरणों को सीधे कोड में देख सकते हैं

```csharp
// 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
```

### सम्मिलन (Local ONNX, प्रथम रन के बाद कैच किया गया

जेनेरेटर v2 एक ONNX मॉडल के प्रयोग से एम्बेडिंग का संगणन कर सकता है `all-MiniLM-L6-v2`पहली बार जब आप इसे चलाते हैं, यह मॉडल डाउनलोड करता है और अपने आउटपुट फ़ोल्डर में vocab

इसका मतलब है

- सर्वप्रथम चलाने के लिए नेटवर्क अभिगम की आवश्यकता है (मोडल डाउनलोड
- अनुवर्ती रन स्थानीय और तेज हैं
- यदि आप चाहते हैं “कभी कोई नेटवर्क नहीं चलाएँ `--no-embeddings`

```csharp
// 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);
}
```

## हम कैसे उत्पन्न करते हैं “LLM-ShapedM SK2Products

उत्पाद उत्पादन प्रवर्धन जानबूझकर सख्त है: एलएलएम को केवल JSON लौटाना होगा, एक सम्मिलित JSON स्कीमा उदाहरण के साथ

```csharp
// 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:
    """;
```

यह महत्व रखता है क्योंकि नीचे की प्रणाली (छवि उत्पन्न करने के लिए | + | आयात |+ | एम्बेडिंग | МSK3 | संरचनात्मक डेटा चाहते हैं *पाइपलाइन में इनपुट*गद्य नहीं लिखता

### LLM प्रतिक्रियाएँ: पद वर्णन JSON, या वापस गिरें

एलएलएम कंपाइलर नहीं हैं

v2 जेनरेटर एक छोटी मददगार के माध्यम से ऐसा करता है`LlmService`) जो पहला निकालता है `{...}` ब्लॉक और इसे डिसेरियालिज़ करता है

```csharp
// 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
    });
}
```

और समग्र उत्पादन पाइपलाइन निर्दिष्ट रूप से उपलब्धता की जांच करता है तथा आवश्यकता पड़ने पर निर्णायक टेम्प्लेटों को कम करने के लिए

```mermaid
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
```

### उदाहरण: ग्राहक व्यक्तित्व (vM SK2

ग्राहकों के लिए व्यक्ति प्रोम्प्ट छोटा और संरचना है इसलिए यह एक छोटे स्थानीय मॉडल के साथ तेजी से उत्पन्न किया जा सकता है

```csharp
// 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"]
    }
    """;
```

## API के माध्यम सेComfyUI: उत्पाद फोटोग्राफी

ComfyUI महान है क्योंकि यह आपको एक नियंत्रित पाइपलाइन देता है (workflows) एकल काला बक्सा छवि अंतबिंदु के बजाय

जेनरेटर

1. एक कार्यप्रवाह टेम्प्लेट लोड करता है (`ComfyUI/workflows/product_image.json`)
2. प्रवर्धन में पैच करता है `CLIPTextEncode`
3. कतार `/prompt`
4. मतदान `/history/{promptId}`
5. छवि डाउनलोड करता है `/view?...`

```mermaid
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 मॉडल चयन भी रनटाइम पर कार्यप्रवाह में पैच किया जाता है (ताकि आप JSON को संपादित किए बिना जाँच बिंदुओं का स्विप कर सकते हैं

```csharp
// 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");
```

और कार्यप्रवाह पैचिंग जानबूझकर सरल और मजबूत है

```csharp
// 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 अनाम प्रोफाइलें बनाता है और फिर उन्हें एक व्यक्तित्व के साथ समृद्ध करता है. ( अभी भी कोई PII नहीं है.

v में प्रोफाइलों को एक के उपयोग से कुंजींकित किया जाता है

```csharp
// 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();
}
```

यह पूरी श्रृंखला की मानसिकता है

```mermaid
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
```

## वैधीकरण: यह आपको क्या साबित करता है

यह स्थानीय पाइपलाइन शक्तिशाली है क्योंकि यह समर्थन करता है *मॉडल वैधीकरण*केवल डेमो नहीं

- **विखंडन स्वच्छता**जब आप उत्पाद नामों की जांच करते हैं तो खंडों को आप संगणित करें
- **सिफारिश का स्पष्टीकरण**क्या करता है “मुझे दिखाता है कि क्यों यह सही संकेत पर संकेत देता है जिसे आप सत्यापित कर सकते हैं
- **ठंडा प्रारंभ**: यदि आप डेटासेट को मिटाना और पुनर्जीवित करें
- **रिग्रेसन परीक्षण**डेटा के एक ही आकार को पुनर्जीवित करें और सुनिश्चित करें कि आपके परिवर्तन रैंकिंग नहीं तोड़ते

महत्वपूर्ण सूक्ष्मता : दोनों के उत्पादन द्वारा *पाठ* और *छवियाँ*आप पूरे उत्पाद अनुभव को प्रमाणित कर सकते हैं

## क्या है

**[भाग 2](/blog/zero-pii-customer-intelligence-part2)**सत्र प्रोफाइलें

**भाग 3** आ रहा है

---


*जेनेरेटर कोड `Mostlylucid.SegmentCommerce.SampleData/`*