News

IBM Research open-sources CoFrNets PyTorch code

Researchers can test continued-fraction layers in place of feed-forward layers. The repository includes examples for function fitting, tabular classification and language modeling.

D
Dec 4, 2026 · 1 min read

IBM Research announced the open-source release of CoFrNets, a set of PyTorch implementations of neural network layers based on continued fractions. Researchers can install the cofrnet package from the public repository and use it to replace a model’s feed-forward layers. The repository’s first public-access time remains unclear.

IBM includes examples for fitting one-dimensional functions, classifying tabular data and training language models with nanoGPT. The nanoGPT example includes a character-level Shakespeare run that works on a CPU and GPT-2 configurations for OpenWebText that use GPUs. The example code can replace a Transformer’s feed-forward layers, attention layers or both.

A continued fraction nests one division inside another. The code evaluates each chain through additions and multiplications and at most one division.

The package offers two presets. The logexp preset uses logarithms and exponentials and sets a floor on the denominator’s magnitude. The default spectral preset changes how the partial denominators are computed so the fraction stays defined. The function-fitting notebook compares three configurations named cap, logexp and spd.

IBM says its gated feed-forward design matched or improved on standard models in some language-model tests with 30% to 50% fewer parameters. In one comparison on MNLI, a language-understanding benchmark, IBM’s researchers reported 87.26% accuracy for their 985-million-parameter CoFrGeNet-FNG model, 86.89% for standard GPT-2 XL at 1.5 billion parameters and 81.17% for a non-expanding GPT-2 XL baseline with 985 million parameters.

The researchers pretrained all three models on OpenWebText and fine-tuned them on GLUE, a suite of language-understanding tasks. The paper reports different rankings across tasks and training datasets. Independent replication of the MNLI result remains undocumented.

IBM lists version 0.1.0.dev0 and requires Python 3.10 or later and PyTorch 2.0 or later for the core package. The repository uses Apache License 2.0 and licenses the adapted nanoGPT example under MIT.

More news