theaithinker commited on
Commit
1cb2daf
·
verified ·
1 Parent(s): 723ccf9

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +144 -3
README.md CHANGED
@@ -1,3 +1,144 @@
1
- ---
2
- license: mit
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ ---
4
+ Model Summary
5
+
6
+ OpenCelestial_1 is a compact and efficient language model fine-tuned on a greeting dataset. It demonstrates that small LLMs can achieve remarkable conversational capabilities, even when trained on consumer-grade hardware.
7
+
8
+ Based on the GPT-2 architecture, OpenCelestial_1 is optimized for clear, polite, and structured responses, making it ideal for use cases such as:
9
+
10
+ Chatbots
11
+ Instruction-following assistants
12
+ Lightweight deployments on limited hardware
13
+
14
+ Model Training
15
+
16
+ Base Model: openai-community/gpt2
17
+ Dataset: Custom greeting dataset with structured "User" and "AI" dialogue pairs.
18
+ Hardware: Fine-tuned on a single NVIDIA RTX 3060.
19
+ Optimization: Fine-tuning utilized LoRA (Low-Rank Adaptation) to improve memory efficiency.
20
+
21
+ Usage Example
22
+
23
+ To interact with OpenCelestial_1, use the following Python script:
24
+
25
+ pip install transformers torch
26
+
27
+ Copy and paste the following script:
28
+
29
+
30
+
31
+ ```python3
32
+ from transformers import GPT2LMHeadModel, GPT2Tokenizer
33
+ import torch
34
+
35
+ # Load the model and tokenizer
36
+ model_path = "./gpt2_lora_alpaca_gpt4"
37
+ model = GPT2LMHeadModel.from_pretrained(model_path)
38
+ tokenizer = GPT2Tokenizer.from_pretrained(model_path)
39
+
40
+ # Set the pad token to the EOS token if not already set
41
+ tokenizer.pad_token = tokenizer.eos_token
42
+
43
+ print("Chatbot is ready! Type 'exit' to quit.")
44
+
45
+ while True:
46
+ user_input = input("You: ")
47
+ if user_input.lower() == "exit":
48
+ print("Chatbot: Goodbye!")
49
+ break
50
+
51
+ # Define the system prompt and the full prompt
52
+ system_prompt = "You are an intelligent AI assistant that will answer every question to the best of your ability. Be clear and polite with your answers."
53
+ prompt = f"{system_prompt}\n### Instruction:\n{user_input}\n### Response:"
54
+
55
+ # Tokenize the input
56
+ inputs = tokenizer(
57
+ prompt,
58
+ return_tensors="pt",
59
+ padding=True,
60
+ truncation=True,
61
+ max_length=1024,
62
+ )
63
+ input_ids = inputs.input_ids.to(model.device)
64
+ attention_mask = inputs.attention_mask.to(model.device)
65
+
66
+ # Generate the response
67
+ with torch.no_grad():
68
+ outputs = model.generate(
69
+ input_ids=input_ids,
70
+ attention_mask=attention_mask,
71
+ max_new_tokens=150,
72
+ pad_token_id=tokenizer.eos_token_id,
73
+ do_sample=True,
74
+ temperature=0.7,
75
+ top_k=50,
76
+ top_p=0.95,
77
+ )
78
+
79
+ # Decode the response and clean it up
80
+ response = tokenizer.decode(outputs[0], skip_special_tokens=True)
81
+ clean_response = response.split("### Response:")[-1].strip()
82
+ print(f"Chatbot: {clean_response}")
83
+ ```
84
+
85
+ Example Outputs
86
+
87
+ Prompt: Hello there!
88
+ Response: Hello there! I am just an AI assistant, but I’m here to help you with anything you need.
89
+
90
+ Prompt: Can you tell me a joke?
91
+ Response: Sure! Why don’t skeletons fight each other? Because they don’t have the guts!
92
+
93
+ Prompt: What is the capital of France?
94
+ Response: The capital of France is Paris.
95
+ Training Details
96
+
97
+ LoRA Configuration:
98
+ Rank (r): 4
99
+ Alpha: 16
100
+ Dropout: 0.1
101
+ Target Modules: GPT-2’s attention layers (attn.c_attn)
102
+ Training Arguments:
103
+ Mixed precision: Enabled (fp16)
104
+ Epochs: 3
105
+ Batch size: 2 (to fit GPU memory)
106
+ Learning rate: 5e-5
107
+
108
+ Performance
109
+
110
+ OpenCelestial_1 demonstrates:
111
+
112
+ Clear conversational ability with polite, structured responses.
113
+ Low resource requirements, suitable for GPUs like the RTX 3060.
114
+ Consistency in instruction-following tasks.
115
+
116
+ Intended Use
117
+
118
+ This model is designed for:
119
+
120
+ Conversational AI applications.
121
+ Instruction-based assistants that respond politely and clearly.
122
+ Lightweight deployments for hobbyists, small-scale developers, or educational purposes.
123
+
124
+ Limitations
125
+
126
+ Responses may still contain hallucinations or factual inaccuracies.
127
+ Performance is limited to the dataset scope and GPT-2’s inherent capabilities.
128
+
129
+ Citation
130
+
131
+ If you use OpenCelestial_1 in your work, please consider citing:
132
+
133
+ @misc{OpenCelestial_1,
134
+ author = {Your Name or Organization},
135
+ title = {OpenCelestial_1: A Compact GPT-2 Fine-Tuned Model},
136
+ year = {2024},
137
+ howpublished = {\url{https://huggingface.co/your_username/OpenCelestial_1}},
138
+ }
139
+
140
+ Acknowledgments
141
+
142
+ Base Model: openai-community/gpt2
143
+ Fine-tuned using the LoRA technique for efficient memory usage.
144
+ Developed on a single NVIDIA RTX 3060 GPU.