Make Word.MergeAll sub-quadratic

Abierto
#7,872 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
42/100
Tipo de issue
Refactorización
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
csharp, machine-learning
Área
performance

Línea de trabajo

The slow path is Word.MergeAll in src/Microsoft.ML.Tokenizers/Model/Word.cs, where symbols are removed from a Vec<T>-style list with Remove() while a PriorityQueue<T> drives the merges. Read that method first and find which tests in the Microsoft.ML.Tokenizers test project cover BPE merging so you can confirm the output is unchanged. Done means the removal no longer shifts the list on every merge, the existing tokenizer tests still pass, and the change is benchmarked against the old version.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

area-Tokenizers tenet-performance

The current implementation of Word.MergeAll uses Vec<T>.Remove() to remove symbols from the list:

https://github.com/dotnet/machinelearning/blob/81310b23aeee0cc12720edde8794e3cc94afef3e/src/Microsoft.ML.Tokenizers/Model/Word.cs#L187-L194

Based on data I found, it seems it's common that around 75 % of symbols are removed here (though the data conflates multiple steps, so it could be not fully relevant). This makes the method quadratic, likely significantly affecting its performance.

We should consider improving that. (This won't make the method linear, since the use of PriorityQueue<T> leads to at least O(n log n).)

Lenguaje dominante
C#
Estrellas
9.4k
Forks
2k
Merge medio
2 d 18 h
PR fusionados (30 d)
64

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de dotnet/machinelearning

Todos los issues de dotnet/machinelearning

Issues similares

Más issues de C#

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.