Skip to content

Commit 3776999

Browse files
committed
Migrate pipeline and services from TensorFlow to PyTorch
Replace TFAutoModel/Keras with PyTorch across the BERT predictor and qgen modules. Pin all dependencies with exact versions and add spaCy language model URLs to requirements. Add integration tests for complexity indices and vector models. Update rb submodule to matching PyTorch migration commit.
1 parent 56e838a commit 3776999

16 files changed

Lines changed: 1120 additions & 405 deletions

File tree

pipeline/management/commands/pipeline_worker.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
def process(job: Job):
2222
import torch
23-
import tensorflow as tf
2423
from rb import Lang
2524
from pipeline.tuning import hyperparameter_search
2625
from pipeline.parallel import build_features
@@ -84,7 +83,6 @@ def process(job: Job):
8483

8584
def predict(job: Job):
8685
import torch
87-
import tensorflow as tf
8886
from rb import Lang
8987
from pipeline.enums import ModelTypeEnum
9088
from pipeline.models import Model
@@ -149,7 +147,6 @@ def predict(job: Job):
149147

150148
def compute_all_indices(job: Job):
151149
import torch
152-
import tensorflow as tf
153150
from rb import Lang
154151
from pipeline.parallel import build_features
155152

pipeline/migrations/0001_initial.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66

77

88
def init_model_types(apps, schema_editor):
9-
from pipeline.enums import ModelTypeEnum
9+
# Hardcoded to avoid importing pipeline.enums (which triggers heavy ML dependencies)
10+
# Keep in sync with pipeline.enums.ModelTypeEnum
1011
from pipeline.models import ModelType
11-
for mt in ModelTypeEnum:
12+
for label in ['TRANSFORMER', 'XGBOOST']:
1213
obj = ModelType()
13-
obj.label = mt.name
14+
obj.label = label
1415
obj.save()
1516

1617
def delete_model_types(apps, schema_editor):

pipeline/parallel.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import pyphen
66
import torch
7-
import tensorflow as tf
87
from rb import Document, Lang
98
from rb.cna.cna_graph import CnaGraph
109
from rb.complexity.complexity_index import compute_indices
@@ -15,8 +14,6 @@
1514

1615
def build_features(text: str, lang: Lang, all_elements=False) -> Dict[str, float]:
1716
Logger.get_logger().setLevel(logging.WARNING)
18-
tf.config.run_functions_eagerly(True)
19-
tf.config.set_visible_devices([], 'GPU')
2017
doc = Document(lang, text)
2118
model = create_vector_model(lang, VectorModelType.TRANSFORMER, "")
2219
model.encode(doc)

0 commit comments

Comments
 (0)