Top AI Repos — open-source AI, indexed and scored
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Implementation of character based convolutional neural network
| Date | Stars |
|---|---|
| 2026-07-31 | 262 |
| 2026-08-06 | 262 |
Today
— stars today
This week
— stars this week
This month
— stars this month
Momentum
0.0
growth rate 0.00%/day
## Character Based CNN
[](https://github.com/ahmedbesbes/character-based-cnn/blob/master/LICENSE)
[](https://github.com/ahmedbesbes/character-based-cnn/issues)
[](https://twitter.com/ahmed_besbes_)
[](https://github.com/ahmedbesbes/character-based-cnn/stargazers)
This repo contains a PyTorch implementation of a character-level convolutional neural network for text classification.
The model architecture comes from this paper: https://arxiv.org/pdf/1509.01626.pdf

There are two variants: a large and a small. You can switch between the two by changing the configuration file.
This architecture has 6 convolutional layers:
|Layer|Large Feature|Small Feature|Kernel|Pool|
|-|-|-|-|-|
|1|1024|256|7|3|
|2|1024|256|7|3|
|3|1024|256|3|N/A|
|4|1024|256|3|N/A|
|5|1024|256|3|N/A|
|6|1024|256|3|3|
and 2 fully connected layers:
|Layer|Output Units Large|Output Units Small|
|-|-|-|
|7|2048|1024|
|8|2048|1024|
|9|Depends on the problem|Depends on the problem|
## Video tutorial
If you're interested in how character CNN work as well as in the demo of this project you can check my youtube video tutorial.
<p align="center">
<a href="https://www.youtube.com/watch?v=CNY8VjJt-iQ">
<img src="https://img.youtube.com/vi/CNY8VjJt-iQ/0.jpg">
</a>
</p>
## Why you should care about character level CNNs
They have very nice properties:
- They are quite powerful in text classification (see paper's benchmark) even though they don't have any notion of semantics
- You don't need to apply any text preprocessing (tokenization, lemmatization, stemming ...) while using them
- They handle misspelled words and OOV (out-of-vocabulary) tokens
- They are faster to train compared to recurrent neural networks
- They are lightweight since they don't require storing a large word embedding matrix. Hence, you can deploy them in production easily
## Training a sentiment classifier on french customer reviews
I have tested this model on a set of french labeled customer reviews (of over 3 millions rows). I reported the metrics in TensorboardX.
I got the following results
||F1 score|Accuracy|
|-|-|-|
|train|0.965|0.9366|
|test|0.945|0.915|

## Dependencies
- numpy
- pandas
- sklearn
- PyTorch 0.4.1
- tensorboardX
- Tensorflow (to be able to run TensorboardX)
## Structure of the code
At the root of the project, you will have:
- **train.py**: used for training a model
- **predict.py**: used for the testing and inference
- **config.json**: a configuration file for storing model parameters (number of filters, neurons)
- **src**: a folder that contains:
- **cnn_model.py**: the actual CNN model (model initialization and forward method)
- **data_loader.py**: the script responsible of passing the data to the training after processing it
- **utils.py**: a set of utility functions for text preprocessing (url/hashtag/user_mention removal)
## How to use the code
### Training
**The code currently works only on binary labels (0/1)**
Launch train.py with the following arguments:
- `data_path`: path of the data. Data should be in csv format with at least a column for text and a column for the label
- `validation_split`: the ratio of validation data. default to 0.2
- `label_column`: column name of the labels
- `text_column`: column name of the texts
- `max_rows`: the maximum number of rows to load from the dataset. (I mainly use this for testing to go faster)
- `chunksize`: size of the chunks when loading the data using pandas. default to 500000
- `encoding`: default to utf-8
- `steps`: text preprocessing steps to inExcerpt of 7,319 characters
Read on GitHubWould you bet a product on this? Bounded 0–100 and slow moving.
matched fp:34298564a8ff4755, topic:nlp, topic:natural-language-processing
matched fp:34298564a8ff4755, topic:pytorch