OPEN-ARC Open Models
Collection
A collection of available base models for our OPEN-ARC project: https://github.com/Infinitode/OPEN-ARC.
•
7 items
•
Updated
Repository: https://github.com/Infinitode/OPEN-ARC/
OPEN-ARC-TWNG is a simple recurrent neural network (RNN) language model developed as part of Infinitode’s OPEN-ARC initiative. It predicts the next token in a sequence using a lightweight architecture suitable for smaller datasets.
Architecture:
Embedding(vocab_size, 500) maps tokens to 500-dimensional vectors.SimpleRNN(50) processes sequences with 50 recurrent units.Dense(vocab_size, activation='softmax') produces a probability distribution over the vocabulary.loss='categorical_crossentropy', optimizer='adam', and tracked accuracy metric.11)| Metric | Value |
|---|---|
| Train Accuracy | 78.6% |
| Validation Accuracy | not used |
| Loss (final) | 0.44 |
import random
def generate_random_name(min_length=3, max_length=10, temperature=1.0, seed_text=""):
# Use a random seed
random.seed()
if seed_text:
# If seed text is provided
generated_name = seed_text
else:
# Randomly select a token from our vocab as our starting token if no seed text is present
random_index = random.randint(1, vocab_size-1)
random_token = sp.id_to_piece(random_index)
generated_name = random_token
# Generate subsequent subword tokens
for _ in range(max_length - 1):
# Encode our starting text
token_list = sp.encode_as_ids(generated_name)
token_list = pad_sequences([token_list], maxlen=max_seq_len-1, padding='pre')
# Run prediction
predicted = model.predict(token_list, verbose=0)[0]
# Apply temperature to predictions, helps to varied results
predicted = np.log(predicted + 1e-8) / temperature
predicted = np.exp(predicted) / np.sum(np.exp(predicted))
# Sample from the distribution
next_index = np.random.choice(range(vocab_size), p=predicted)
next_index = int(next_index)
next_token = sp.id_to_piece(next_index)
# Add the predicted token to our output
generated_name += next_token
# Decode the generated subword tokens into a string
decoded_name = sp.decode_pieces(generated_name.split())
# Stop if end token is predicted (optional, based on your dataset), or stop if max_length is reached
if next_token == '' or len(decoded_name) > max_length:
break
# Replace underscores with spaces
decoded_name = decoded_name.replace("▁", " ")
# Remove stop tokens from the output
decoded_name = decoded_name.replace("</s>", "")
# Capatilize the first letter of each word
generated_name = decoded_name.rsplit(' ', 1)[0]
generated_name = generated_name[0].upper() + generated_name[1:]
# Split the name and check the last part, make sure that it is not cut off
parts = generated_name.split()
if parts and len(parts[-1]) < min_length:
generated_name = " ".join(parts[:-1])
# Strip the output to ensure no extra whitespace
return generated_name.strip()
For questions or issues, open a GitHub issue or reach out at https://infinitode.netlify.app/forms/contact.