Texar: A TensorFlow 1.x Toolkit for Text Generation, Pinned Below TensorFlow 2.0
Toolkit for Machine Learning, Natural Language Processing, and Text Generation, in TensorFlow. This is part of the CASL project: http://casl-project.ai/
At a glance
- What is it?
- Texar is a modular TensorFlow library for NLP and text generation from the CASL project, with encoder-decoder, pre-trained model and reinforcement learning components behind one hyperparameter-driven API. Its hard version ceiling on TensorFlow 1.x is the first thing to weigh before adopting it.
- Who is it for?
- Adopt Texar if your stack is already on TensorFlow 1.10 through 1.x and you want encoder-decoder, pre-trained and RL components behind one hyperparameter interface, or if you need both the TF and PyTorch variants to share an API. Do not adopt it if you are starting on TensorFlow 2.x, since the install notes cap the dependency below 2.0.0 and the latest tagged release is v0.2.4 from November 2019.
- Can I use it commercially?
- Yes. Apache-2.0 is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 57 days ago.
- What is it written in?
- Mainly Python, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on September 15, 2026, and from our analysis. They are not legal advice.
DEEP OPEN-SOURCE ANALYSIS
The gap Texar was built to fill in TensorFlow NLP code
Writing an encoder-decoder text generation model in TensorFlow 1.x usually means assembling attention, embedding tying, sequence masking and decoding loops by hand, then rewriting the same plumbing when you switch from maximum likelihood training to reinforcement learning. Texar's stated aim is to remove that plumbing. The README describes it as a toolkit that provides "a library of easy-to-use ML modules and functionalities for composing whatever models and algorithms", aimed at "both researchers and practitioners for fast prototyping and experimentation." The intended user is someone who wants to vary the training objective or the model architecture without rebuilding the data pipeline. The same code block in the README builds a Transformer encoder-decoder, then shows the same decoder reused for adversarial learning and for policy gradient learning. That reuse is the actual product. The audience is not someone who wants a single pretrained model to call; it is someone who wants to compose parts.
Modules, data iterators and hyperparameter dicts: the mechanism
Texar is organized around a small number of namespaces. In the README example, tx.data.PairedTextData takes a hparams_data dict and returns an object wrapped by tx.data.DataIterator, which yields batches through get_next(). Model pieces live under tx.modules: WordEmbedder, TransformerEncoder, TransformerDecoder and beam_search_decode. Losses live under tx.losses, including sequence_sparse_softmax_cross_entropy, binary_adversarial_losses and the agent under tx.agents.SeqPGAgent. The README states the design is "based on principled decomposition of Learning-Inference-Model Architecture", which in practice means the model, the decoding strategy and the learning objective are separate arguments rather than one fused training script. The decoder call shows this directly: the same decoder object accepts decoding_strategy='greedy_train' for teacher forcing, or a helper such as GumbelSoftmaxTraingHelper for sampling, and the README notes the decoder variables are re-used automatically. Configuration is passed as dicts of hyperparameters rather than constructor arguments, which is what allows the same module to be reconfigured without code changes. The README also states Texar is fully compatible with native TensorFlow APIs, so modules can be mixed with hand-written TF ops.
Installing Texar: version windows you have to respect
The installation section is unusually explicit about constraints. Texar requires tensorflow >= 1.10.0 but < 2.0.0, and tensorflow_probability >= 0.3.0 but < 0.8.0. The README also carries a note: "Texar>0.2.3 requires Python 3.6 or 3.7. To use with older Python versions, please use Texar<=0.2.3." Once TensorFlow and tensorflow_probability are installed, the install is a single pip command: pip install texar. For unreleased features the README gives the source route: git clone https://github.com/asyml/texar.git, cd texar, pip install . The two version windows are the part that will bite. A modern environment ships TensorFlow 2.x by default, and tensorflow_probability releases move in step with it, so the upper bounds on both packages force you to pin an older combination deliberately rather than let pip resolve. Because the repository has no release newer than v0.2.4 (tagged 2019-11-19) in the supplied material, there is no version of Texar documented here that relaxes the TensorFlow 2.0 ceiling.
Pre-trained models and the two-framework bet
The feature list names BERT, GPT2 and XLNet as pre-trained models usable "for encoding, classification, generation, and composing complex models with other Texar components." The README's adversarial example uses tx.modules.BertClassifier as a discriminator, which is the pattern the project is selling: a pre-trained encoder is just another module you can drop into a larger graph. The second bet is the paired implementation. Texar-TensorFlow and Texar-PyTorch are described as having "mostly the same interfaces", combining "Interfaces and variable sharing in PyTorch convention" with "Excellent factorization and rich functionalities in TF convention." The word "mostly" is doing real work there. If you need one codebase that runs under both frameworks, the shared interface is the reason to pick Texar over writing against TensorFlow directly. If you only ever intend to use TensorFlow, that portability buys you nothing and you are paying for a second implementation you will not use. The README also points to a mirror maintained by Petuum Open Source, and credits Petuum and CMU as the original developers.
Where Texar is the wrong tool
The TensorFlow 1.x ceiling is the clearest failure mode. TensorFlow 1.x graph-mode code, tf.Session and the tf.placeholder style of data feeding are not what new projects are written in, and the README does not describe a compatibility layer or an upgrade path. If your team has moved to TensorFlow 2.x, adopting Texar means maintaining a separate pinned environment for it. The second constraint is tensorflow_probability, capped below 0.8.0. Probabilistic modelling is one of the listed capabilities, so anyone drawn to Texar for that reason is also the most exposed to the version window. Third, the release cadence visible in the supplied material is slow: v0.2.2, v0.2.3 and v0.2.4 landed between August and November 2019, and there is nothing newer listed. That does not prove the project is abandoned (the repository is not archived and the last push date is recent), but it does mean you should not expect fixes for new TensorFlow or Python releases to arrive quickly. Finally, if you want a pretrained model you can call in three lines, Texar is the wrong shape: it is a composition toolkit, and the README's own examples show you wiring data, modules and losses together yourself.
Texar-PyTorch as the alternative, and how the approach differs
The obvious alternative is the sibling repository the README links: Texar-PyTorch. The difference is not feature coverage, it is the execution model. Texar-TensorFlow builds on TensorFlow 1.x graph construction, so a model is a graph you assemble and then run through a session, and tensorflow_probability supplies the probabilistic primitives. Texar-PyTorch keeps the same module names and hyperparameter-dict configuration but runs under eager execution, where the decoder call in the README example would execute immediately rather than build a node. That matters if you want to debug by printing intermediate tensors, or if your team's other code is already PyTorch. The cost is that the interfaces are only "mostly" the same, so code is not guaranteed to move across unchanged, and the two repositories are maintained separately. Outside the Texar family, the honest comparison is plain TensorFlow or PyTorch with a pretrained-model library: you would write the encoder-decoder and decoding loop yourself and get a dependency set that tracks current framework releases. What you lose is the uniform hyperparameter interface and the ability to swap a greedy decoding strategy for Gumbel-softmax sampling or a policy gradient agent without restructuring the model.
Maintenance cost and the Apache-2.0 terms
Texar is licensed Apache-2.0, which permits commercial and closed-source use, modification and redistribution provided the licence and attribution notices are preserved and any modified files carry prominent change notices; it also includes an explicit patent grant. That is the permissive end of the spectrum and is the reason a company could vendor Texar into an internal product. It is not legal advice, and the usual caveat applies: the pre-trained models the README names (BERT, GPT2, XLNet) come with their own upstream licences, and Texar's Apache-2.0 grant covers Texar's code, not those weights. The maintenance cost is dominated by the version pinning. Every time you rebuild an environment you are resolving TensorFlow below 2.0.0 and tensorflow_probability between 0.3.0 and 0.8.0, on Python 3.6 or 3.7 for Texar above 0.2.3. Those are the numbers to put in a lockfile, and they are the numbers that will conflict first when a base image moves. Budget for a frozen environment rather than an upgrade path, because the supplied material shows no release that changes the ceiling.
Editorial conclusion
Adopt Texar if your stack is already on TensorFlow 1.10 through 1.x and you want encoder-decoder, pre-trained and RL components behind one hyperparameter interface, or if you need both the TF and PyTorch variants to share an API. Do not adopt it if you are starting on TensorFlow 2.x, since the install notes cap the dependency below 2.0.0 and the latest tagged release is v0.2.4 from November 2019. Verify first that tensorflow_probability can be resolved inside the 0.3.0 to 0.8.0 window alongside your TensorFlow build, then run the encoder-decoder example from the README against your own data before committing.
Community notes