diff --git a/examples/quick_start_guide.py b/examples/quick_start_guide.py new file mode 100644 index 0000000..f9e3788 --- /dev/null +++ b/examples/quick_start_guide.py @@ -0,0 +1,43 @@ +"""Quick Start Guide with Practical Examples""" + +from jsonformer import Jsonformer +from transformers import AutoModelForCausalLM, AutoTokenizer + +# Load small model for quick testing +print("Loading model (this may take a minute first time)...") +model = AutoModelForCausalLM.from_pretrained("microsoft/DialoGPT-small") +tokenizer = AutoTokenizer.from_pretrained("microsoft/DialoGPT-small") +if tokenizer.pad_token is None: + tokenizer.pad_token = tokenizer.eos_token + +# Example 1: Simple User Profile +print("\n=== Example 1: User Profile ===") +user_schema = { + "type": "object", + "properties": { + "username": {"type": "string"}, + "age": {"type": "number"}, + "is_premium": {"type": "boolean"}, + "interests": {"type": "array", "items": {"type": "string"}}, + }, +} +jsonformer = Jsonformer(model, tokenizer, user_schema, "Generate a user profile:") +print(jsonformer()) + +# Example 2: Product Information +print("\n=== Example 2: Product Info ===") +product_schema = { + "type": "object", + "properties": { + "name": {"type": "string"}, + "price": {"type": "number"}, + "in_stock": {"type": "boolean"}, + "tags": {"type": "array", "items": {"type": "string"}}, + }, +} +jsonformer = Jsonformer( + model, tokenizer, product_schema, "Generate product information:" +) +print(jsonformer()) + +print("\nAll examples completed!")