Compare commits
No commits in common. "ba126bbce3b40f0f8d1b324dad381488c247f1f5" and "7d1f2ac3faa891c6ff0b3f80f2b83e9d0eb748fa" have entirely different histories.
ba126bbce3
...
7d1f2ac3fa
1
.gitignore
vendored
1
.gitignore
vendored
@ -170,4 +170,3 @@ cython_debug/
|
|||||||
|
|
||||||
/tokenizer_vocab.txt
|
/tokenizer_vocab.txt
|
||||||
/logs/core_dreams.txt
|
/logs/core_dreams.txt
|
||||||
/logs/best_dream.txt
|
|
13
dashboard.py
13
dashboard.py
@ -12,13 +12,6 @@ def tail(filepath, num_lines=10):
|
|||||||
return f.readlines()[-num_lines:]
|
return f.readlines()[-num_lines:]
|
||||||
|
|
||||||
|
|
||||||
def get_best_dream():
|
|
||||||
if not os.path.exists("logs/best_dream.txt"):
|
|
||||||
return "No high-scoring dream yet."
|
|
||||||
with open("logs/best_dream.txt", encoding="utf-8") as f:
|
|
||||||
return f.read().strip()
|
|
||||||
|
|
||||||
|
|
||||||
@app.route("/")
|
@app.route("/")
|
||||||
def home():
|
def home():
|
||||||
vocab_size = 0
|
vocab_size = 0
|
||||||
@ -29,7 +22,6 @@ def home():
|
|||||||
dreams = [line.strip() for line in tail("logs/dreams.log", 10)]
|
dreams = [line.strip() for line in tail("logs/dreams.log", 10)]
|
||||||
messages = [line.strip() for line in tail("logs/messages.log", 10)]
|
messages = [line.strip() for line in tail("logs/messages.log", 10)]
|
||||||
errors = [line.strip() for line in tail("logs/error.log", 15)]
|
errors = [line.strip() for line in tail("logs/error.log", 15)]
|
||||||
best_dream = get_best_dream()
|
|
||||||
|
|
||||||
return render_template_string("""
|
return render_template_string("""
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
@ -47,8 +39,6 @@ def home():
|
|||||||
<body>
|
<body>
|
||||||
<h1>🌸 Ruby's Dashboard</h1>
|
<h1>🌸 Ruby's Dashboard</h1>
|
||||||
<p><b>Vocabulary Size:</b> {{ vocab_size }}</p>
|
<p><b>Vocabulary Size:</b> {{ vocab_size }}</p>
|
||||||
<h3>🏆 Highest Scoring Dream</h3>
|
|
||||||
<p><b>{{ best_dream }}</b></p>
|
|
||||||
|
|
||||||
<h3>🧠 Recent Daydreams</h3>
|
<h3>🧠 Recent Daydreams</h3>
|
||||||
<ul>
|
<ul>
|
||||||
@ -70,10 +60,9 @@ def home():
|
|||||||
{{ err }}
|
{{ err }}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
""", best_dream=best_dream, dreams=dreams[::-1], messages=messages[::-1], errors=errors[::-1], vocab_size=vocab_size)
|
""", dreams=dreams[::-1], messages=messages[::-1], errors=errors[::-1], vocab_size=vocab_size)
|
||||||
|
|
||||||
|
|
||||||
def start_dashboard():
|
def start_dashboard():
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
|
||||||
class RubyState:
|
class RubyState:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.last_message_time = datetime.utcnow()
|
self.last_message_time = datetime.utcnow()
|
||||||
|
10
trainer.py
10
trainer.py
@ -19,7 +19,6 @@ class RubyTrainer:
|
|||||||
self.criterion = torch.nn.CrossEntropyLoss()
|
self.criterion = torch.nn.CrossEntropyLoss()
|
||||||
|
|
||||||
self.rebuild_model_if_needed()
|
self.rebuild_model_if_needed()
|
||||||
self.best_dream = ("", 0.0)
|
|
||||||
|
|
||||||
def rebuild_model_if_needed(self):
|
def rebuild_model_if_needed(self):
|
||||||
vocab_size = len(self.tokenizer.vocab)
|
vocab_size = len(self.tokenizer.vocab)
|
||||||
@ -157,8 +156,7 @@ class RubyTrainer:
|
|||||||
|
|
||||||
score_raw = self.score_sentence(raw)
|
score_raw = self.score_sentence(raw)
|
||||||
score_re = self.score_sentence(rephrased)
|
score_re = self.score_sentence(rephrased)
|
||||||
if score_re >= self.best_dream[1]:
|
|
||||||
self.best_dream = (rephrased.strip(), score_re)
|
|
||||||
final = rephrased if score_re >= score_raw else raw
|
final = rephrased if score_re >= score_raw else raw
|
||||||
|
|
||||||
self.train_on_tokens_from_text(final)
|
self.train_on_tokens_from_text(final)
|
||||||
@ -184,8 +182,6 @@ class RubyTrainer:
|
|||||||
f.write(f"{datetime.utcnow().isoformat()} | Ruby | {t}\n")
|
f.write(f"{datetime.utcnow().isoformat()} | Ruby | {t}\n")
|
||||||
|
|
||||||
print(f"[DAYDREAM] Complete. {len(thoughts)} thoughts imagined.")
|
print(f"[DAYDREAM] Complete. {len(thoughts)} thoughts imagined.")
|
||||||
with open("logs/best_dream.txt", "w", encoding="utf-8") as f:
|
|
||||||
f.write(f"{self.best_dream[1]:.2f} | {self.best_dream[0]}\n")
|
|
||||||
|
|
||||||
if say_thought and thoughts:
|
if say_thought and thoughts:
|
||||||
return thoughts[-1]
|
return thoughts[-1]
|
||||||
@ -250,8 +246,4 @@ class RubyTrainer:
|
|||||||
if len(set(words)) > len(words) * 0.75:
|
if len(set(words)) > len(words) * 0.75:
|
||||||
score += 1 # diversity bonus
|
score += 1 # diversity bonus
|
||||||
|
|
||||||
word_counts = {w: words.count(w) for w in set(words)}
|
|
||||||
if any(count >= 3 for count in word_counts.values()):
|
|
||||||
score -= 1 # repetition penalty
|
|
||||||
|
|
||||||
return score # max 5.0
|
return score # max 5.0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user