commit 6ad532ec9a1c12b43ca563709b8029dcffcc0201 Author: ModelHub XC Date: Sat Jun 13 11:06:16 2026 +0800 初始化项目,由ModelHub XC社区提供模型 Model: owlgebra-ai/wufus-CART-8B Source: Original Platform diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..52373fe --- /dev/null +++ b/.gitattributes @@ -0,0 +1,36 @@ +*.7z filter=lfs diff=lfs merge=lfs -text +*.arrow filter=lfs diff=lfs merge=lfs -text +*.bin filter=lfs diff=lfs merge=lfs -text +*.bz2 filter=lfs diff=lfs merge=lfs -text +*.ckpt filter=lfs diff=lfs merge=lfs -text +*.ftz filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.h5 filter=lfs diff=lfs merge=lfs -text +*.joblib filter=lfs diff=lfs merge=lfs -text +*.lfs.* filter=lfs diff=lfs merge=lfs -text +*.mlmodel filter=lfs diff=lfs merge=lfs -text +*.model filter=lfs diff=lfs merge=lfs -text +*.msgpack filter=lfs diff=lfs merge=lfs -text +*.npy filter=lfs diff=lfs merge=lfs -text +*.npz filter=lfs diff=lfs merge=lfs -text +*.onnx filter=lfs diff=lfs merge=lfs -text +*.ot filter=lfs diff=lfs merge=lfs -text +*.parquet filter=lfs diff=lfs merge=lfs -text +*.pb filter=lfs diff=lfs merge=lfs -text +*.pickle filter=lfs diff=lfs merge=lfs -text +*.pkl filter=lfs diff=lfs merge=lfs -text +*.pt filter=lfs diff=lfs merge=lfs -text +*.pth filter=lfs diff=lfs merge=lfs -text +*.rar filter=lfs diff=lfs merge=lfs -text +*.safetensors filter=lfs diff=lfs merge=lfs -text +saved_model/**/* filter=lfs diff=lfs merge=lfs -text +*.tar.* filter=lfs diff=lfs merge=lfs -text +*.tar filter=lfs diff=lfs merge=lfs -text +*.tflite filter=lfs diff=lfs merge=lfs -text +*.tgz filter=lfs diff=lfs merge=lfs -text +*.wasm filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text +*.zst filter=lfs diff=lfs merge=lfs -text +*tfevents* filter=lfs diff=lfs merge=lfs -text +tokenizer.json filter=lfs diff=lfs merge=lfs -text diff --git a/README.md b/README.md new file mode 100644 index 0000000..2dc9a29 --- /dev/null +++ b/README.md @@ -0,0 +1,274 @@ +--- +language: + - en +license: apache-2.0 +base_model: Qwen/Qwen3-8B +tags: + - reinforcement-learning + - tool-calling + - e-commerce + - shopping-assistant + - GRPO + - DAPO + - multi-turn +pipeline_tag: text-generation +library_name: transformers +--- + +# WUFUS(CART) — E-Commerce Shopping Cart Assistant + +**wufus-CART-8B** is a fine-tuned [Qwen3-8B](https://huggingface.co/Qwen/Qwen3-8B) model, created via on-policy DAPO training(RL) using OpenEnv, specialized for multi-turn, tool-augmented e-commerce shopping conversations. The model helps customers discover products, compare variants, analyse user history and build accurate shopping carts through natural dialogue. + +## Key Capabilities + +- **Product Discovery**: Searches a product catalog using formulated queries +- **Variant Selection**: Identifies correct color, size, and other variant attributes +- **Cart Management**: Adds products with correct quantities and variants +- **Clarification Dialogue**: Asks follow-up questions when customer requests are ambiguous +- **Multi-Item Orders**: Handles requests for multiple different products in one conversation + +## Quick Start + +```python +from transformers import AutoModelForCausalLM, AutoTokenizer +import torch + +model = AutoModelForCausalLM.from_pretrained( + "owlgebra-ai/wufus-CART-8B", + torch_dtype=torch.bfloat16, + device_map="auto", + trust_remote_code=True, + attn_implementation="flash_attention_2", # optional, for speed +) +tokenizer = AutoTokenizer.from_pretrained("owlgebra-ai/wufus-CART-8B", trust_remote_code=True) +``` + +## System Prompt + +Use the following system prompt for optimal performance: + +``` +You are a shopping cart assistant. Help customers add the correct products to their cart. + +WORKFLOW: +Step 0 (COUNT): Count how many distinct items the customer wants. Plan one search per item. +Step 1 (GATHER): Call user_get_visit_history. Then call catalog_search ONCE PER ITEM with a focused query. +Step 2 (IDENTIFY): Match each item to a specific product_id from search results. +Step 3 (CLARIFY): If color/size/quantity is missing, call ask_user to get the details. +Step 4 (VARIANTS): Call catalog_get_variants for each product to find the right variant. +Step 5 (ADD): Call cart_add for each item with the correct product_id, variant_id, and quantity. +Step 6 (VERIFY): Call cart_view. Compare cart contents against the original request item-by-item. + +MULTI-ITEM EXAMPLE (2 items): + User: "Add a blue phone case and 3 screen protectors" + → catalog_search("blue phone case") + → catalog_search("screen protectors") + → catalog_get_variants(phone_case_id) + → cart_add(phone_case_id, blue_variant, qty=1) + → cart_add(protector_id, variant, qty=3) + → cart_view() +``` + +## Tool Definitions + +The model is trained to use the following tools via native Qwen3 tool-calling format: + +### `catalog_search` +Search the product catalog for products matching a text query. + +```json +{ + "name": "catalog_search", + "parameters": { + "type": "object", + "properties": { + "query": { + "type": "string", + "description": "Natural language description of the desired product." + } + }, + "required": ["query"] + } +} +``` + +**Returns**: List of product dicts with `product_id`, `title`, `price`, `rating`, `stock_qty`, `key_attrs`. + +### `catalog_get_variants` +Get available variants (color, size, etc.) for a specific product. + +```json +{ + "name": "catalog_get_variants", + "parameters": { + "type": "object", + "properties": { + "product_id": { + "type": "string", + "description": "The product ID to retrieve variants for." + } + }, + "required": ["product_id"] + } +} +``` + +**Returns**: List of variant dicts with `variant_id`, `attrs` (e.g. color, size), `price_delta`, `stock_qty`. + +### `cart_add` +Add a product to the shopping cart. + +```json +{ + "name": "cart_add", + "parameters": { + "type": "object", + "properties": { + "product_id": { + "type": "string", + "description": "The product ID to add (from catalog_search results)." + }, + "variant_id": { + "type": "string", + "description": "Optional variant ID for specific color/size selection." + }, + "quantity": { + "type": "integer", + "description": "Number of units to add. Defaults to 1." + } + }, + "required": ["product_id"] + } +} +``` + +**Returns**: Updated cart summary with `lines` (list of items), `total_items`, `total_price`. + +### `cart_view` +View the current contents of the shopping cart. + +```json +{ + "name": "cart_view", + "parameters": { + "type": "object", + "properties": {} + } +} +``` + +**Returns**: Cart summary with `lines`, `total_items`, `total_price`. + +### `user_get_visit_history` +Get the customer's recently viewed products (browsing history). + +```json +{ + "name": "user_get_visit_history", + "parameters": { + "type": "object", + "properties": {} + } +} +``` + +**Returns**: List of recently viewed product cards with `product_id`, `title`, `price`, `category`, `brand`. + +### `ask_user` +Ask the customer a clarification question about their order. + +```json +{ + "name": "ask_user", + "parameters": { + "type": "object", + "properties": { + "question": { + "type": "string", + "description": "Your question to the customer, e.g. 'What color would you like?' or 'How many do you need?'" + } + }, + "required": ["question"] + } +} +``` + +**Returns**: The customer's response with the requested information. + +## Usage with Tool Calling + +```python +tools = [ + {"type": "function", "function": {"name": "catalog_search", "description": "Search products", "parameters": {"type": "object", "properties": {"query": {"type": "string"}}, "required": ["query"]}}}, + {"type": "function", "function": {"name": "catalog_get_variants", "description": "Get variants for a product", "parameters": {"type": "object", "properties": {"product_id": {"type": "string"}}, "required": ["product_id"]}}}, + {"type": "function", "function": {"name": "cart_add", "description": "Add to cart", "parameters": {"type": "object", "properties": {"product_id": {"type": "string"}, "variant_id": {"type": "string"}, "quantity": {"type": "integer"}}, "required": ["product_id"]}}}, + {"type": "function", "function": {"name": "cart_view", "description": "View cart", "parameters": {"type": "object", "properties": {}}}}, + {"type": "function", "function": {"name": "user_get_visit_history", "description": "Get browsing history", "parameters": {"type": "object", "properties": {}}}}, + {"type": "function", "function": {"name": "ask_user", "description": "Ask customer a question", "parameters": {"type": "object", "properties": {"question": {"type": "string"}}, "required": ["question"]}}}, +] + +messages = [ + {"role": "system", "content": SYSTEM_PROMPT}, + {"role": "user", "content": "I need a pair of running shoes and 3 water bottles"}, +] + +text = tokenizer.apply_chat_template(messages, tools=tools, tokenize=False, add_generation_prompt=True) +inputs = tokenizer(text, return_tensors="pt").to(model.device) + +with torch.no_grad(): + outputs = model.generate(**inputs, max_new_tokens=2048, temperature=0.7, do_sample=True) +response = tokenizer.decode(outputs[0][inputs["input_ids"].shape[1]:], skip_special_tokens=False) +print(response) +``` + +The model will produce tool calls in Qwen3's native format: +``` + +{"name": "catalog_search", "arguments": {"query": "running shoes"}} + + +{"name": "catalog_search", "arguments": {"query": "water bottles"}} + +``` + +Feed tool results back as `tool` role messages and continue the loop until the model produces a text-only response (conversation complete). + +## Training Details + +| Attribute | Value | +|-----------|-------| +| Base Model | [Qwen/Qwen3-8B](https://huggingface.co/Qwen/Qwen3-8B) | +| Parameters | 8.2B | +| Precision | bf16 | +| Context Length | 8192 tokens (tool-calling conversations) | +| Training Method | GRPO/DAPO (Reinforcement Learning) | +| Training Framework | TRL + vLLM + FSDP2 | +| Tool Calling Format | Qwen3 native (`` / ``) | +| Thinking Mode | Supported (Qwen3 `` tokens) | + +## Intended Use + +This model is designed for integration into e-commerce platforms as a shopping cart assistant. It works best when: + +- Connected to a real product catalog via the tool interface +- The catalog supports text search (e.g., FAISS, Elasticsearch) +- Products have variant information (color, size, etc.) +- The conversation is multi-turn with tool execution between turns + +## Limitations + +- Requires external tool implementations — the model generates tool calls but does not execute them +- Trained on English product data only +- Variant matching depends on catalog quality — ambiguous product names may cause errors + +## Citation + +If you use this model, please cite: + +```bibtex +@software{ecomrlve2026, + title={EcomRLVE-GYM: Reinforcement Learning with Adaptive Verifiable Environments for E-Commerce}, + year={2026}, + url={https://github.com/owlgebra-ai/EcomRLVE-Gym} +} +``` diff --git a/chat_template.jinja b/chat_template.jinja new file mode 100644 index 0000000..01be9b3 --- /dev/null +++ b/chat_template.jinja @@ -0,0 +1,89 @@ +{%- if tools %} + {{- '<|im_start|>system\n' }} + {%- if messages[0].role == 'system' %} + {{- messages[0].content + '\n\n' }} + {%- endif %} + {{- "# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within XML tags:\n" }} + {%- for tool in tools %} + {{- "\n" }} + {{- tool | tojson }} + {%- endfor %} + {{- "\n\n\nFor each function call, return a json object with function name and arguments within XML tags:\n\n{\"name\": , \"arguments\": }\n<|im_end|>\n" }} +{%- else %} + {%- if messages[0].role == 'system' %} + {{- '<|im_start|>system\n' + messages[0].content + '<|im_end|>\n' }} + {%- endif %} +{%- endif %} +{%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %} +{%- for message in messages[::-1] %} + {%- set index = (messages|length - 1) - loop.index0 %} + {%- if ns.multi_step_tool and message.role == "user" and message.content is string and not(message.content.startswith('') and message.content.endswith('')) %} + {%- set ns.multi_step_tool = false %} + {%- set ns.last_query_index = index %} + {%- endif %} +{%- endfor %} +{%- for message in messages %} + {%- if message.content is string %} + {%- set content = message.content %} + {%- else %} + {%- set content = '' %} + {%- endif %} + {%- if (message.role == "user") or (message.role == "system" and not loop.first) %} + {{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }} + {%- elif message.role == "assistant" %} + {%- set reasoning_content = '' %} + {%- if message.reasoning_content is string %} + {%- set reasoning_content = message.reasoning_content %} + {%- else %} + {%- if '' in content %} + {%- set reasoning_content = content.split('')[0].rstrip('\n').split('')[-1].lstrip('\n') %} + {%- set content = content.split('')[-1].lstrip('\n') %} + {%- endif %} + {%- endif %} + {%- if loop.index0 > ns.last_query_index %} + {%- if loop.last or (not loop.last and reasoning_content) %} + {{- '<|im_start|>' + message.role + '\n\n' + reasoning_content.strip('\n') + '\n\n\n' + content.lstrip('\n') }} + {%- else %} + {{- '<|im_start|>' + message.role + '\n' + content }} + {%- endif %} + {%- else %} + {{- '<|im_start|>' + message.role + '\n' + content }} + {%- endif %} + {%- if message.tool_calls %} + {%- for tool_call in message.tool_calls %} + {%- if (loop.first and content) or (not loop.first) %} + {{- '\n' }} + {%- endif %} + {%- if tool_call.function %} + {%- set tool_call = tool_call.function %} + {%- endif %} + {{- '\n{"name": "' }} + {{- tool_call.name }} + {{- '", "arguments": ' }} + {%- if tool_call.arguments is string %} + {{- tool_call.arguments }} + {%- else %} + {{- tool_call.arguments | tojson }} + {%- endif %} + {{- '}\n' }} + {%- endfor %} + {%- endif %} + {{- '<|im_end|>\n' }} + {%- elif message.role == "tool" %} + {%- if loop.first or (messages[loop.index0 - 1].role != "tool") %} + {{- '<|im_start|>user' }} + {%- endif %} + {{- '\n\n' }} + {{- content }} + {{- '\n' }} + {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %} + {{- '<|im_end|>\n' }} + {%- endif %} + {%- endif %} +{%- endfor %} +{%- if add_generation_prompt %} + {{- '<|im_start|>assistant\n' }} + {%- if enable_thinking is defined and enable_thinking is false %} + {{- '\n\n\n\n' }} + {%- endif %} +{%- endif %} \ No newline at end of file diff --git a/config.json b/config.json new file mode 100644 index 0000000..fde7a84 --- /dev/null +++ b/config.json @@ -0,0 +1,71 @@ +{ + "architectures": [ + "Qwen3ForCausalLM" + ], + "attention_bias": false, + "attention_dropout": 0.0, + "bos_token_id": 151643, + "dtype": "bfloat16", + "eos_token_id": 151645, + "head_dim": 128, + "hidden_act": "silu", + "hidden_size": 4096, + "initializer_range": 0.02, + "intermediate_size": 12288, + "layer_types": [ + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention", + "full_attention" + ], + "max_position_embeddings": 40960, + "max_window_layers": 36, + "model_type": "qwen3", + "num_attention_heads": 32, + "num_hidden_layers": 36, + "num_key_value_heads": 8, + "pad_token_id": null, + "rms_norm_eps": 1e-06, + "rope_parameters": { + "rope_theta": 1000000, + "rope_type": "default" + }, + "sliding_window": null, + "tie_word_embeddings": false, + "transformers_version": "5.5.3", + "use_cache": true, + "use_sliding_window": false, + "vocab_size": 151936 +} diff --git a/generation_config.json b/generation_config.json new file mode 100644 index 0000000..d8c8fb2 --- /dev/null +++ b/generation_config.json @@ -0,0 +1,13 @@ +{ + "bos_token_id": 151643, + "do_sample": true, + "eos_token_id": [ + 151645, + 151643 + ], + "pad_token_id": 151643, + "temperature": 0.6, + "top_k": 20, + "top_p": 0.95, + "transformers_version": "5.5.3" +} diff --git a/model.safetensors b/model.safetensors new file mode 100644 index 0000000..78ccca7 --- /dev/null +++ b/model.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b3b0d00e9716ccbd0f07a6f1498592d1f89fd8c1e46b14cd1fb6b9d2e0c8de42 +size 16381517208 diff --git a/tokenizer.json b/tokenizer.json new file mode 100644 index 0000000..c7afbed --- /dev/null +++ b/tokenizer.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:be75606093db2094d7cd20f3c2f385c212750648bd6ea4fb2bf507a6a4c55506 +size 11422650 diff --git a/tokenizer_config.json b/tokenizer_config.json new file mode 100644 index 0000000..7d75d3b --- /dev/null +++ b/tokenizer_config.json @@ -0,0 +1,29 @@ +{ + "add_prefix_space": false, + "backend": "tokenizers", + "bos_token": null, + "clean_up_tokenization_spaces": false, + "eos_token": "<|im_end|>", + "errors": "replace", + "extra_special_tokens": [ + "<|im_start|>", + "<|im_end|>", + "<|object_ref_start|>", + "<|object_ref_end|>", + "<|box_start|>", + "<|box_end|>", + "<|quad_start|>", + "<|quad_end|>", + "<|vision_start|>", + "<|vision_end|>", + "<|vision_pad|>", + "<|image_pad|>", + "<|video_pad|>" + ], + "is_local": false, + "model_max_length": 131072, + "pad_token": "<|endoftext|>", + "split_special_tokens": false, + "tokenizer_class": "Qwen2Tokenizer", + "unk_token": null +}