AI

AI

How to test a hypothesis by AI?

Reading Time: < 1 minute

The traditional hypothesis testing I learned in school involves this:

  1. Stating with null hypothesis, which assumes no effects, and
  2. Alternative hypothesis, which state there is an effect.

So we can make the null hypothesis that “Earth is flat”, and the alternative hypothesis that Earth is not flat.

For humans, we can explore the physical world and design experiments to disapprove the null hypothesis. But for a AI, assuming these is no way for the AI to interact with the world through physics. How we can we truly test the hypothesis?

One way to go about this is find a general consensus amongst human knowledge. For example, using Google search result to see whether human agree on the hypothesis. This of course doesn’t mean that human consensus is the truth. In the early times, the consensus was that “Earth is flat”, and the consensus only changed recently if we consider the whole span of human consensus. It is very likely that the human consensus will change over time.

So what then? Do we believe that if AI cannot interact with the physical world, then it cannot prove or disapprove a hypothesis? Is there any alternative? Is there even an approximation? Is it possible that we can deduce from logic and evidence, that upon the collection of enough evidence and applying proper logic that we can disapprove the null hypothesis without physically interact with the world? Sometimes theoretical physics prove the existence of certain things before experiment verification.

AI, Journal

What to do if Ubuntu doesn’t wake up after sleep

Reading Time: < 1 minute

So I recently updated my linux machine to Ubuntu 20.04 and it didn’t wake up from sleep. The behavior is black screen and a restart after about 10 minutes of wait. The solution I found that worked is this -> https://askubuntu.com/questions/1298198/ubuntu-20-04-doesnt-wake-up-after-suspend

Hopefully that solves your problems! Anniversary Edition!

AI, Journal, Misc

OpenVPN

Reading Time: < 1 minute

I made an attempt to install OpenVPN using linuxserver.io‘s docker image. I tried Docker compose version but hit this error:

You can configure manually using the /usr/local/openvpn_as/bin/ovpn-init tool.
/var/lib/dpkg/info/openvpn-as.postinst: line 72: systemctl: command not found

After a little digging in the log file, it said:

Error: Could not execute 'systemctl enable openvpnas' to enable startup/shutdown scripts

I tried to search some error and github page said they are working on it. I then went to this page and there seems to be a solution by changing the config.json file.

https://forums.unraid.net/topic/79012-support-linuxserverio-openvpn-as/page/71/

But I tried that by execute into the docker container, execute this:

/usr/local/openvpn_as/scripts/sacli --key "vpn.server.daemon.enable" --value "false" ConfigPut
/usr/local/openvpn_as/scripts/sacli --key "vpn.daemon.0.listen.protocol" --value "tcp" ConfigPut
/usr/local/openvpn_as/scripts/sacli --key "vpn.server.port_share.enable" --value "true" ConfigPut
/usr/local/openvpn_as/scripts/sacli start

This however didn’t work either. There seems to be other tutorials using straight docker and get to the admin page. So I can only say it’s the mentioned multiprocessing problem, and I will have to wait to a working update.

AI, Journal

Causal Inference Book

Reading Time: < 1 minute

Recently started reading the causal inference book, Counterfactuals and Causal Inference, by Stephen Morgan and Christopher Winship. Link to book. This book was recommended by researchers at the ACL conference. I personally found Pearl’s 2009 book to hard to read and his popular book less detailed. This book started with the history and included other researches done in the field. So after I get partly through the backdoor criterion section, I decided to program it using networkx. I have just gone through the part where I check if the backdoor criterion is satisfied. https://github.com/yangliu2/frontal Will implement the part that will recommend variables to condition to prove the causal relationship.

AI, Journal, NLP

Use Tensorflow without having AVX instruction set on your old CPUs

Reading Time: < 1 minute

Working on the repurposed Dell r710 server I got, I mostly want to run Machine Learning algorithms on it. Specifically, I wanted to run the Universal Sentence Encoder to generate sentence embeddings. But the pip installed version of Tensorflow doesn’t work with the E5660 CPU I have because it requires AVX CPU instruction set. Without it, it will just give me Illegal instruction (core dumped) message. I can kind of get around it by using the Anaconda version of Tensorflow. One exception I found is that the multi-language pre-trained model require tensorflow_text package. This packages is not compatible with the Ananconda version of TensorFlow for some reason. So once again, I’m left with the only option for English text and cannot compare sentence embedding across different languages.

AI, Journal

Containerize Everything

Reading Time: < 1 minute

In an effort to curb my video game playing hobby, and be close to my wife, I have been trying to stand up a bunch of machine learning services on my home server. I tried to do some standard things like WordPress and a regular website, but this proved to be inconsistent and tedious to configure. I decided to just pay for those services. But I’m designing more ML/AI oriented projects such as how to design a computer learning system similar to the human brain. And from previous experience, it seems that docker-compose is a good choice. Both for its ease to configure (someone did the job already in a docker container), and for modularity (I can start/stop a server without destroying my Linux server). So I decided to just use the latest docker images for things like MongoDB. The idea is to have each container do one type of service, and share the docker volume to a host/local folder for easier replication when I move to a different server. For this MongoDB container, I mostly followed the guide at this

dev.to tutorial

The only change I made was to change the volume to a local folder rather than docker volume so I can access it easier with greater modularization. Obviously this is not for production usage, but it’s sufficient enough for my own usages.

version: '3.7'
services:
  mongodb_container:
    image: mongo:latest
    container_name: mongo_db_main
    environment:
      MONGO_INITDB_ROOT_USERNAME: root
      MONGO_INITDB_ROOT_PASSWORD: rootpassword
    ports:
      - 27017:27017
    volumes:
      - ./mongodb_data_container:/data/db

Now you can use this to access the Mongodb.

mongo --username <username> --password <password> --host <ip address>

AI, NLP, Reinforcement Learning

Using reinforcement learning for Conversation understanding

Reading Time: 3 minutes

I went to the NeurIPS 2019 conference in December and focused on NLP and reinforcement learning (RL) topics. The former is what I do for work, analyzing call center conversations, understanding what works for customer interactions, and make suggestions to clients based on their data. The latter is my personal interest, started all the way back when DeepMind beat the world’s best Go players. At the RL sessions, the tutorials mentioned using imitation learning to do natural language understanding tasks and generate responses to questions or chit-chat. People have some success, but it has some of the common pitfalls like repetitive usage of the most likely responses, and responses being too short. And sometimes the response is too simple and the bots fall into a cycle of “I don’t understand what you are saying”. So one night at a social gathering, I did get to meet Drs. David Silver and Richard Sutton. They briefly mentioned that I could try to set up the RL environment like a conversation and see if the agents can learn from the conversations. And in one of the workshops related to NLG conversations, people have talked about using various rewards to penalize for repetitiveness and encourage the generation of different texts. So that got me thinking. In addition to making a chatbot that’s similar to a call-center agent and customer interactions, I can design an environment that helps me discover the reason why people are calling. What I can do is set up categories of actions that are similar to “give refund”, “cancel service”, “keep the customer on the phone” etc, and use (regret = current action – best action), when the reward is either made the customer happy for 1 or made customer mad for 0. This may help me find the best action in a specific situation that results in the most wanted outcome given by the client. Granted, this might not give me the causal reasons why did the customer call directly, but it’s more similar to me designing a potential causal relationship graph before making the model and test if the causal relationship is correct. Even if it does not give me the exact cause, if it gives me the best action to take, then at least I have a product that does what the clients want. So the goal of the new year is to design an environment so I can test this idea and see if I can get the best type of action to take.

To get myself familiarize with the Gym framework from Open.Ai, I set up my own card game environment and made a double deep q-learning network. So here are some resources if you want to start your own:

Taking some design hints from https://github.com/zmcx16/OpenAI-Gym-Hearts
Some more help to design the environment: https://datascience.stackexchange.com/questions/28858/card-game-for-gym-reward-shaping
Other projects using gym: https://awesomeopensource.com/projects/openai-gym
Probably already programmed here: https://awesomeopensource.com/project/datamllab/rlcard
Create your own gym environments: https://github.com/openai/gym/blob/master/docs/environments.md https://stable-baselines.readthedocs.io/en/master/guide/custom_env.html https://github.com/openai/gym/blob/master/docs/creating-environments.md https://towardsdatascience.com/creating-a-custom-openai-gym-environment-for-stock-trading-be532be3910e https://medium.com/@apoddar573/making-your-own-custom-environment-in-gym-c3b65ff8cdaa

For the environment I look for in the conversation task, I will need to have an environment that mimics a conversation. A reset would result in starting a new conversation. Render is just how the conversation carried before a specific point. Each step can be a turn of the conversation, with texts randomly chosen from the same category pool. A downside I can see with this approach is that the training data might not generate the best solution to the customer service session. It may just be the bare minimum to get to the desired outcome. But I hope that the fact I can design my own regret in an RL framework, I can penalize for things like the length of the conversation or sentiment/emotional outcome, while I’m trying to achieve the outcome of retaining a customer.

I have encountered a similar situation before when I was making a chatbot using Rasa. They have a simpler RL environment, where a user can choose which route to take in a certain situation. But when I used it, the policy was too simple and does not achieve what I want, especially not give a causal relationship. I hope this could be integrated into this framework and be more useful.

AI, NLP

Combining multiple modalities of inputs in Neural Networks

Reading Time: < 1 minute

Recently, we have been trying to identify the emotion or sentiment in a phone conversation. The first step we have tried to use a while back was Universal Sentence Embedding. That algorithm transforms a sentence into a fix length sentence embedding or 512 numbers. But we are ignoring the acoustic features all together with this approach. We are getting 0.70 on test accuracy on about 2000 sentences/utterances, but hoping to do better. So we started trying to combine text embedding with acoustic features such as MFCC and may others offered by Librosa. I used an LSTM with features for each window as the time steps over however many windows I have. Of course, I had to pad to the maximum number of windows. I tried to even include all the features librosa offered but was not able to increase the accuracy of more than 0.73. After the concatenation layer of text and audio signals, I played around with both LSTM and Dense layers, with just dense layers being more accurate. I suspect there just aren’t enough samples, especially consider the LSTM for the acoustic signals. So will try to see if I can get more labeled data for the audio signal to improve accuracy.

AI, Reinforcement Learning

Introduction to Reinforcement Learning 2

Reading Time: < 1 minute

So continuing the journey on learning RL, I went through the deep Q blog.

https://www.freecodecamp.org/news/an-introduction-to-deep-q-learning-lets-play-doom-54d02d8017d8/

Now this time it required more setup on the colab environment. First, you got to make sure you can install the VizDoom package on colab. There are some dependencies needs to be satisfied. Also make sure you install scikit-image package. This takes about 10 minutes as the package need to be build using CMAKE.

Then I initially just pulled the stock “basic.cfg”, “basic.wad” file of the github site. But found out later that had problems. The big one being the frame was sampled in RGB and give you the wrong dimensions. So now I just download them from the github with the already setup config files. Nevertheless, it helped me to understand what was passed around.

A big thing to learn was, of course, the Deep Q network. Which is in the class “DQNetwork”. I’m more used to program in Keras, so it takes a little more time to understand. You can do this in Keras, although you need to update loss function, which is actually easier to understand to in TensorFlow.

The rest seems straightforward, just let it run and learn. Here is the full colab link.

https://colab.research.google.com/drive/1gZM4pAfH4kroa_44gNYZEE8RDVMiO9cP

AI, Reinforcement Learning

Introduction to Reinforcement Learning 1

Reading Time: < 1 minute

As I discussed before, there are not at many good reinforcement learning material out there. But I found this great set of tutorial and I will share my journey of learning it.

Start reading these two set of of blogs,

  1. Blog Number 1
  2. Blog Number 2

At the end of the second blog, you will find jupyter notebook for the Frozen Lake tutorial.

https://github.com/simoninithomas/Deep_reinforcement_learning_Course/blob/master/Q%20learning/FrozenLake/Q%20Learning%20with%20FrozenLake_unslippery%20(Deterministic%20version).ipynb

Before you start the tutorial, you will like need to learn how the Gym environment works. Go to this link and read the super basic tutorial they have there. Note especially what are the component of each episode. Actually figure out what are the possible actions, and what does each value of the state means.

http://gym.openai.com/docs/

Here is the wiki for the basic parameters. https://github.com/openai/gym/wiki/CartPole-v0

Refer to the source for what “Discrete” and “Box” are. https://github.com/openai/gym/tree/master/gym/spaces

Run the code on Google Colab and see how it runs. Print out the variable for each episode and step. I made an example in case you want to follow. https://colab.research.google.com/drive/1oqon14Iq8jzx6PhMJvja-mktFTru5GPl

Run the deterministic state first and then stochastic. Now you know how to create the super basic, Q table.

View More