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
داخل الجزء الأول لقد غطينا الفلسفة: تقسيم شفاف بدون PII. الجزء الثاني تشمل موجزات الدورات، والإشارات، وتعاريف الأجزاء.
أولاً: كيف يمكنك التحقق من صحة أي من هذا دون أي وقت مضى لمس بيانات العملاء الحقيقية؟
ولأجل هذه السلسلة، أُنشئ مجموعة كاملة من بيانات التجارة الإلكترونية الاصطناعية محلياً:
هذا واحد من تلك "يشعر وكأنه غش" تدفق العمل: تحصل على مدخلات واقعية، يمكنك تجديدها في أي وقت، وأنت أبداً لا تقدم PCI في بيئتك.
إذا كنت تبني تجزئة/شخصية، فإنك تحتاج إلى مجموعات بيانات:
البيانات الحقيقية هي العكس: حساسة، فوضوية، من الصعب التحرك حولها، ومليئة بالتحيز التاريخي.
بيانات الاقتران تعطيك ثلاث قوى خارقة:
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.
وليس عن قصد " إطار عمل " ؛ بل عن طريق مبادرة خارجية عملية تتحدث عن:
إعدادات هو مُثبّت فوق لذا أنت يُمْكِنُ أَنْ تُحرّكَه عبر بيئة المتغيرات:
// Mostlylucid.SegmentCommerce.SampleData/Program.cs
var configuration = new ConfigurationBuilder()
.SetBasePath(AppContext.BaseDirectory)
.AddJsonFile("appsettings.json", optional: true)
.AddEnvironmentVariables("SAMPLEDATA_")
.Build();
تقوم عادة بإدارة ثلاث خدمات محلية إلى جانب المولد:
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
تنفيذ المولّد من جذر:
dotnet run --project Mostlylucid.SegmentCommerce.SampleData -- status
ثمّ توليد a البيانات:
# 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
مُستخدِم المُمَزِل:
# 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
ملاحظة: إذا لم يكن الموّلد V1 متاحاً، فإن المولّد V1 يعود إلى الصور ذات المكان (الاستخدامات) picsum.photosإذاً هذا الطريق ليس "متوقفاً تماماً عن العمل". --no-images.
هناك أيضاً أمر مولد جديد (gen) التي تبني مجموعة بيانات "على شكل سوق" أكثر اكتمالاً:
# 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
إنها مدبرة كخط أنابيب متعدد المراحل:
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
ويمكنك أن ترى تلك المراحل مباشرة في الشفرة:
// 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 أن يحاسب عمليات التضمين باستخدام نموذج OONNX (الافتراض: all-MiniLM-L6-v2في المرة الأولى التي تقوم بتشغيلها، تقوم بتحميل النموذج وتوجيهه إلى مجلد مخرجاتك.
وهذا يعني:
--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);
}
والدافع إلى توليد المنتج صارم عن عمد: إذ يجب على LLLM أن تعيد JUSON فقط، مع وجود نموذج مضمن لمخطط JSON.
// 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:
""";
هذا مهم لأن النظم النهائية (توليد الصورة + الاستيراد + التضمين) تريد بيانات منظمة. LLM تنتج. إلى خط أنابيبلا كتابات.. لا كتابات.. لا كتابات..
وحتى مع عبارة "Json فقط"، لا تزال تحتاج إلى مقولة دفاعية ورجوع رشيق.
مولّد v2 يفعل ذلك عن طريق مساعد صغيرLlmServiceأن يستخرج الأول {...} ويجسيدها على النحو التالي:
// 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
});
}
وخطوط الانابيب العامة للجيل تقوم صراحة بالتحقق من مدى توافرها وانخفاضها إلى قوالب محددة عند الحاجة:
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
والدافع الشخصي للزبائن قصير ومهيكل بحيث يمكن توليده بسرعة بنموذج محلي صغير:
// 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 عظيم لأنه يعطيك خط أنابيب يمكن التحكم فيه (تدفقات العمل) بدلاً من "نقطة نهاية صورة الصندوق الأسود الوحيد".
المولّد:
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 مُرَحَّل أيضاً إلى تدفق العمل في وقت التنفيذ (لذا يمكنك مبادلة نقاط التفتيش بدون تحرير Json):
// 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");
و تنسيق تدفق العمل بسيط و قوي عمداً:
// 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). وينتهي بك الأمر إلى الحصول على بيانات اختبار "شخصية" واقعية من دون رسائل بريد إلكتروني أو عناوين أو أي شيء يمكن أن تشحنه عن طريق الخطأ.
في v1، يتم تحديد الملامح باستخدام هش أحادي الاتجاه، لذلك لا يوجد شيء "لاستعادة":
// 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();
}
وهذه هي بالضبط عقلية السلسلة الكاملة : لا يمكنك ان تتسرب ما لم تخزنه قط .
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
خط الأنابيب المحلي هذا قوي لأنه يدعم ألف - المصادقة على نموذجليس فقط عروضاً عرضية
المعامله المهمه المهمه: عن طريق توليد كلا النص النص وقد عقد مؤتمراً )١يمكنك التحقق من كامل خبرة المنتج، وليس فقط الرياضيات الخلفية.
الجزء الثاني: موجزات الجلسة، الإشارات، وتعاريف الأجزاء حيث نقوم بتوصيل بيانات العينة هذه إلى تقسيم عملي.
الجزء الثالث نمط صندوق الخروج، طابور الوظائف، والشفافية UI.
رمز التشغيل: Mostlylucid.SegmentCommerce.SampleData/
© 2026 Scott Galloway — Unlicense — All content and source code on this site is free to use, copy, modify, and sell.