Outgrowing Brendan Eich’s orders of mission, scope, clojure, prototyping, asynchronicity, ES6 and more great libs turned javascript into a red hot IT topic. Let’s synthesize this wealth and build an evolution where only functionalities and expressed intentions matter. Get ready for neural fun!!!
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Designing nlp-js-extension
1. Designing a NLP based
Multipurpose Javascript Extension
#FrontConf alain.lompo@senacor.com #alainlompo
2. About me
Alain Lompo
Software developer at Senacor
Working on eBanking agile projects
Currently using
Java/JEE or Spring boot in the backend
Angular/React on the frontend (with javascript of course)
Worked a lot previously with .Net technologies
MCSD .Net / MCT, …
Also old times MVP (Windows System / Biztalk Server),
3. Plan
Motivation
The javascript phenomenon:
How to build a javascript extension
Natural language processing: core concepts
Demo
Deep learning and neural networks in javascript
Demo
Wrapping up
4. Motivation
It would be awesome to be able to communicate precise
intent to our IDE or Webapp through natural language
instructions
Wether they come through text typing or vocal commands
It could make of programming in general and web development
in particular a more attractive discipline
Productive level software development would be accessible to
more disabled people
…
5. The javascript phenomenon
Javascript is taking over everything
They nevertheless hate it…?
Syndrome of Stockholm?
Is javascript still weird?
6. Javascript is taking over everything
I ran a software business for a couple of years. I got bought and
Right now I am developing the very product I used to sell. My former
Employees put AngularJs and Node.js in there. I remember my conversation
3 years ago with my best engineer. he said that javascript was taking over
Everything. I though „Wow. They managed to fix that horrible language“
8. They nevertheless hate it…?
At my new company, everyone was pretending that JS was alright.
I got tired and spoke up. Turns out, deep down they all hated JS,
it was just crowd thinking. Now they all hate JS.
And we’re waiting impatiently for Web Assembly.
9. Stockholm syndrome…?
Of all the supportive messages I’ve received over the years,
this is one of my favourites. It confirms what I knew all along:
that JavaScript programmers have been mind-fucked
into thinking that JavaScript is a good programming language.
The president speaks of “mass psychosis”
and “crowd thinking” but I’ve used the analogy of Stockholm syndrome
and cult psychology. Think Patty Hearst and Scientology.
10. Is javascript still weird?
YES !!!
Fail silently at runtime
Callback hell (worked around with promises)
Weak typing
And many more… (https://github.com/denysdovhan/wtfjs)
But constantly improving
Jslint, Eslint, Tslint and similar linters…
The use of new libraries that help reduce the weirdness
The improvements from the last standard releases of javascripts
And many more… (https://github.com/sorrycc/awesome-javascript)
11. How to build a js extension
How easy is that?
Major goals of an extension
Using functions and templates
12. How easy is that?
It can be very easy with a little bit of discipline
The DOM manipulations capabilities make the language
powerful
Allmost everything can be achieved with pure javascript
functionalities
13. Major goals of an extension
Zero external dependencies (as less as possible otherwise)
Reusability and easy to use
Efficiency (minimal size and processing load)
14. DOM manipulation abilities
// Listening to events
document.getElementById("viewerId").addEventListener
("click", this.viewerZoomIn);
// Dynamically update any attribute of any element
document.getElementById("previewerId").src = ...
// Directly enrich html content
var firstLevelHeading =
document.createElement("h1");
var headingText = document.createTextNode("Bird eye
preview");
firstLevelHeading.appendChild(headingText);
document.body.appendChild(firstLevelHeading);
15. NLP core concepts
NLP is not a theory but rather a model
It is a generative and not a repair model
It strives to detect the structure behind human language
To the contrary to the human conscious mind, modern CPUs
are potentially limitless (availability of computational power)
16. The challenge of ambiguity
It originates from
Words with multiple definitions (the same word means
something else depending on the context)
Long sentences
17. Structuring the language
Uses the parse (or syntactic) tree
Originates in generative grammar
Sentences in any language are being generated by a set of rules
Any grammatical sentence can be generated by these rules
Any non – grammatical sentence weren’t and can’t be generated by them
20. Deep learning and neural networks in javascript
Deep learning and javascript should go hand in hand
Javascript is crossplatform, therefore deep learning apps
will run on more platforms
Will reach a wider audience
Will become more visual and interactive
Will benefit from one of the biggest realistic data source
possible
On the other hand, deep learning
Will help make web apps more (artificially…) intelligent
21. More advantages of web deep learning
Reduced server costs
Lowered inference latency
Data privacy
Instant GPU acceleration
Instant access (no complex or constraining setup required)
22. Deep learning
Neural networks
Machine learning
Artificial intelligence
Symbolic AI
Kernel methods
Decision trees
Shallow
Neural
Network
…
…
Machine learning Venn diagram
23. The machine learning paradigm
Training Inference
Training phase Inference phase
Data
Answers
Model architecture
Rules
New data
Answer
24. General approach
Reading/Training dataset
Defining the neural network architecture
Defining the loss function and optimiser method
Training the neural network based on data batches
Evaluating the performances over the test data
27. Wrapping up
Javascript has come a long way from its initial design and
intent
It is now one of the most popular programming language
Though it retains many of its original flaws/weirdness it is
made stronger by a very strong open source community
Being cross platform and offering a huge amount of real life
datas, it is a perfect fit for deep learning
28. Wrapping up
Already many extensions are provided by the community to
allow NLP with javascript such as:
Compromise
Superscriptjs
Dialogflow
Azure text analytics
Retextjs
Opennlp (with its nodejs wrapper: node opennlp)