Machines are possible to have some artificial intelligence like human beings owing to particular algorithms or software. Such machines could learn knowledge from what people taught them and do works according to the knowledge. In practical learning cases, the data is often extremely complicated and large, thus classical learning machines often need huge computational resources. Quantum machine learning algorithm, on the other hand, could be exponentially faster than classical machines using quantum parallelism. Here, we demonstrate a quantum machine learning algorithm on a four-qubit NMR test bench to solve an optical character recognition problem, also known as the handwriting recognition. The quantum machine learns standard character fonts and then recognize handwritten characters from a set with two candidates. To our best knowledge, this is the first artificial intelligence realized on a quantum processor. Due to the widespreading importance of artificial intelligence and its tremendous consuming of computational resources, quantum speedup would be extremely attractive against the challenges from the Big Data.