shreyask commited on
Commit
ac7577a
·
verified ·
1 Parent(s): d118fa3

fix: LR schedule + analogy tab defaults

Browse files
Files changed (2) hide show
  1. app.py +4 -4
  2. microembeddings.py +3 -1
app.py CHANGED
@@ -209,13 +209,13 @@ with gr.Blocks(title="microembeddings", theme=gr.themes.Soft()) as demo:
209
  "Computed as: `B - A + C ≈ ?`"
210
  )
211
  with gr.Row():
212
- a_input = gr.Textbox(label="A", placeholder="king", value="king")
213
- b_input = gr.Textbox(label="B", placeholder="man", value="man")
214
  c_input = gr.Textbox(label="C", placeholder="woman", value="woman")
215
  analogy_btn = gr.Button("Solve", variant="primary")
216
  gr.Examples(
217
- [["king", "man", "woman"], ["paris", "france", "germany"],
218
- ["big", "bigger", "small"]],
219
  inputs=[a_input, b_input, c_input]
220
  )
221
  analogy_text = gr.Textbox(label="Results", interactive=False, lines=6)
 
209
  "Computed as: `B - A + C ≈ ?`"
210
  )
211
  with gr.Row():
212
+ a_input = gr.Textbox(label="A", placeholder="man", value="man")
213
+ b_input = gr.Textbox(label="B", placeholder="king", value="king")
214
  c_input = gr.Textbox(label="C", placeholder="woman", value="woman")
215
  analogy_btn = gr.Button("Solve", variant="primary")
216
  gr.Examples(
217
+ [["man", "king", "woman"], ["france", "paris", "germany"],
218
+ ["bigger", "big", "small"]],
219
  inputs=[a_input, b_input, c_input]
220
  )
221
  analogy_text = gr.Textbox(label="Results", interactive=False, lines=6)
microembeddings.py CHANGED
@@ -80,7 +80,9 @@ def train(corpus, vocab_size, neg_dist, epochs=EPOCHS, embed_dim=EMBED_DIM,
80
  W = (np.random.randn(vocab_size, embed_dim) * scale).astype(np.float32)
81
  C = np.zeros((vocab_size, embed_dim), dtype=np.float32)
82
 
83
- total_steps = epochs * len(corpus)
 
 
84
  step = 0
85
  losses = []
86
 
 
80
  W = (np.random.randn(vocab_size, embed_dim) * scale).astype(np.float32)
81
  C = np.zeros((vocab_size, embed_dim), dtype=np.float32)
82
 
83
+ # Each corpus position generates ~window context pairs on average
84
+ # (random window from 1..window, mean = (window+1)/2, times 2 sides)
85
+ total_steps = epochs * len(corpus) * window
86
  step = 0
87
  losses = []
88