Skip to content

Commit

Permalink
Create entity_recognition.py
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored May 11, 2024
1 parent 0245df4 commit c9ad987
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions natural_language_processing/entity_recognition.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import tensorflow as tf

def train_entity_recognition_model(data, labels, config):
# Define the model architecture
model = tf.keras.Sequential([
tf.keras.layers.Embedding(config['vocab_size'], config['embedding_dim'], input_length=config['max_sequence_length']),
tf.keras.layers.Bidirectional(tf.keras.layers.LSTM(config['hidden_units'], return_sequences=True)),
tf.keras.layers.Dense(config['output_units'], activation=config['output_activation'])
])

# Compile the model
model.compile(optimizer=config['optimizer'],
loss=config['loss'],
metrics=[config['metric']])

# Train the model
model.fit(data, labels, epochs=config['epochs'], batch_size=config['batch_size'])

return model

0 comments on commit c9ad987

Please sign in to comment.