fastai
English
code

Run this model with HF Jobs

Run dnnsdunca/AgenticDeveloper on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.

Paste one of these prompts into your coding agent:

Fine-tune on my dataset

Use HF Jobs to fine-tune https://huggingface.co/dnnsdunca/AgenticDeveloper. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.

Run batch inference

Use HF Jobs to run batch inference with https://huggingface.co/dnnsdunca/AgenticDeveloper on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
File size: 3,279 Bytes
8054e8f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import gradio as gr
import tensorflow as tf
import numpy as np
from datasets import load_dataset
from network import create_text_neural_network, create_gating_network
from agent import PrimeAgent, SecondaryAgent

# Verify GPU availability
print("Num GPUs Available: ", len(tf.config.list_physical_devices('GPU')))

# Define the model training and evaluation function
def train_and_test_model(epochs, batch_size):
    vocab_size = 10000
    embedding_dim = 128
    input_length = 100
    num_classes = 10
    num_experts = 3  # Number of experts

    # Create models for the gating network and secondary agents
    gating_network = create_gating_network((input_length,), num_experts)
    expert_networks = [create_text_neural_network(vocab_size, embedding_dim, input_length, num_classes) for _ in range(num_experts)]
    
    # Define specialties for secondary agents
    specialties = ['code writing', 'code debugging', 'code optimization']

    # Create secondary agents
    secondary_agents = [SecondaryAgent(expert_networks[i], specialties[i]) for i in range(num_experts)]

    # Create prime agent with secondary agents
    prime_agent = PrimeAgent(gating_network, secondary_agents)

    # Load dataset using Hugging Face datasets library
    dataset = load_dataset('imdb')
    train_data = np.array([example['text'][:input_length] for example in dataset['train']])
    train_labels = np.array([example['label'] for example in dataset['train']])
    test_data = np.array([example['text'][:input_length] for example in dataset['test']])
    test_labels = np.array([example['label'] for example in dataset['test']])

    # Convert text to numerical data (tokenization)
    tokenizer = tf.keras.preprocessing.text.Tokenizer(num_words=vocab_size)
    tokenizer.fit_on_texts(train_data)
    train_data = tokenizer.texts_to_sequences(train_data)
    test_data = tokenizer.texts_to_sequences(test_data)
    train_data = tf.keras.preprocessing.sequence.pad_sequences(train_data, maxlen=input_length)
    test_data = tf.keras.preprocessing.sequence.pad_sequences(test_data, maxlen=input_length)

    # Train and test the prime agent's model
    results = ""
    with tf.device('/GPU:0'):
        prime_agent.gating_network.fit(train_data, train_labels, epochs=epochs, batch_size=batch_size)
        test_loss, test_acc = prime_agent.gating_network.evaluate(test_data, test_labels, verbose=2)
        results += f'Gating Network Test Accuracy: {test_acc}\\n'
        
        for expert in prime_agent.experts:
            expert.model.fit(train_data, train_labels, epochs=epochs, batch_size=batch_size)
            test_loss, test_acc = expert.model.evaluate(test_data, test_labels, verbose=2)
            results += f'{expert.specialty.capitalize()} Expert Test Accuracy: {test_acc}\\n'

    return results

# Define the Gradio interface
gr_interface = gr.Interface(
    fn=train_and_test_model,
    inputs=[
        gr.inputs.Slider(minimum=1, maximum=50, step=1, default=10, label="Epochs"),
        gr.inputs.Slider(minimum=16, maximum=512, step=16, default=128, label="Batch Size")
    ],
    outputs="text",
    title="Developer Assistant Training Interface",
    description="Adjust the training parameters and train the model."
)

# Launch the interface
gr_interface.launch()